b=''
>>> print('hello,',b or 'world')
hello, world
我发现,里面只要是空格,就会输出空格,''代表着Flase所以才输出后面的,而' <空格>'就是代表字符是True,所以会输出
a=' '
>>> print('b',a or 'c')
>>> print('hello,',b or 'world')
hello, world
我发现,里面只要是空格,就会输出空格,''代表着Flase所以才输出后面的,而' <空格>'就是代表字符是True,所以会输出
a=' '
>>> print('b',a or 'c')
2021-06-18
s1 = 'ABC'
D = '123'
E = 'xyz'
for a in s1:
for b in D:
for c in E:
print(a + b + c)
print(b + a + c)
print(a + c + b)
print(b + c + a)
print(c + a + b)
print(c + b + a)
D = '123'
E = 'xyz'
for a in s1:
for b in D:
for c in E:
print(a + b + c)
print(b + a + c)
print(a + c + b)
print(b + c + a)
print(c + a + b)
print(c + b + a)
2021-06-18
print(r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2021-06-17
num=0
sum=0
while True:
if num>1000:
break
sum=sum+num
num=num+2
print(sum)
这样可以么
sum=0
while True:
if num>1000:
break
sum=sum+num
num=num+2
print(sum)
这样可以么
2021-06-16
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
for a in L:
sa = (a[0]*a[1]+a[1]*a[2]+a[0]*a[2])*2
print(sa)
22
62
82
for a in L:
sa = (a[0]*a[1]+a[1]*a[2]+a[0]*a[2])*2
print(sa)
22
62
82
2021-06-12
def greet(s='world'):
return 'Hello,{}.'.format(s)
print(greet())
print(greet('Python'))
输出:
Hello,world.
Hello,Python.
return 'Hello,{}.'.format(s)
print(greet())
print(greet('Python'))
输出:
Hello,world.
Hello,Python.
2021-06-10
num = 0
sum = 0
while True:
if num > 1000:
break
if num % 2 == 0 :
sum = num + sum
num = num + 1
print(sum) =》 250500
sum = 0
while True:
if num > 1000:
break
if num % 2 == 0 :
sum = num + sum
num = num + 1
print(sum) =》 250500
2021-06-10
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key in d:
value = d[key]
for ch in value:
print (key,ch)
for key in d:
value = d[key]
for ch in value:
print (key,ch)
2021-06-04
print("这是一句中英文混合的%s字符串:%s"%("python","Hello\tWorld"))
2021-06-02
template1="Life is short"
template2="you need python"
print("{0},{1}".format(template1,template2))
template="{L},{y}"
L="life is short"
y="you need python"
print(template.format(L=L,y=y))
template2="you need python"
print("{0},{1}".format(template1,template2))
template="{L},{y}"
L="life is short"
y="you need python"
print(template.format(L=L,y=y))
2021-06-02
print(r'''"To be, or not to be":that is the question
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2021-06-02