在此平台上,只能加UTF-8,不加u, 才能通过。
用别的编译器,或者这种方法,或者不加UTF-8,但加u,都能通过。
用别的编译器,或者这种方法,或者不加UTF-8,但加u,都能通过。
2018-10-19
def move(n, a, b, c):
if n==1:
print a,'-->',c
return
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
return
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
2018-10-18
L = range(1, 101)
print L[0:10]
r = []
for x in L:
if x % 3 ==0:
r.append(L[x-1])
print r
t=[]
for y in L:
if y > 50:
continue
else:
if y % 5==0:
t.append(L[y-1])
y+=1
print t
print L[0:10]
r = []
for x in L:
if x % 3 ==0:
r.append(L[x-1])
print r
t=[]
for y in L:
if y > 50:
continue
else:
if y % 5==0:
t.append(L[y-1])
y+=1
print t
2018-10-17
for x in range(1,10):
for y in range(1,10):
if x < y:
#print str(x)+str(y)
#print x*10+y
print '%s%s'%(x, y)
for y in range(1,10):
if x < y:
#print str(x)+str(y)
#print x*10+y
print '%s%s'%(x, y)
2018-10-17
# three
new_self_d_c = {}
new_self_d_c['yesterday'] = 20181016
new_self_d_c['today'] = 20181017
new_self_d_c['tomorrow'] = 20181018
print(new_self_d_c)
#four
new_self_d_s = dict(masa = '1435', score = '54' )
print(new_self_d_s)
#five
new_self_d_L = {k: 90 for k in 'num_self'}
print(new_self_d_L)
new_self_d_c = {}
new_self_d_c['yesterday'] = 20181016
new_self_d_c['today'] = 20181017
new_self_d_c['tomorrow'] = 20181018
print(new_self_d_c)
#four
new_self_d_s = dict(masa = '1435', score = '54' )
print(new_self_d_s)
#five
new_self_d_L = {k: 90 for k in 'num_self'}
print(new_self_d_L)
2018-10-17
通过这里dict的创建方式可以看出, 是直接创建的方式,在运用过程中为了区别list,可以用以下比较明显的方式可以创建出:
# one:
new_self_d_a = dict((['Adam','95'],['Lisa','85'],['Bart','59']))
print (new_self_d_a)
#two:
new_self_d_ = dict.fromkeys(['tom','alen','sara'] , 789)
print(new_self_d_)
# one:
new_self_d_a = dict((['Adam','95'],['Lisa','85'],['Bart','59']))
print (new_self_d_a)
#two:
new_self_d_ = dict.fromkeys(['tom','alen','sara'] , 789)
print(new_self_d_)
2018-10-17
print [x*100+y*10+z for x in range(1,10) for y in range(0,10) for z in range(1,10) if x==z]
2018-10-16