‘里面如有有转义字符’,'''可以先去掉各种转移字符,然后加上'''即可输出。
2019-11-23
def square_of_sum(L):
sum=0
for x in L:
sum=sum+s*s
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum=0
for x in L:
sum=sum+s*s
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-11-21
age = 8
if age >= 18:
print 'adult'
elif age >= 6:
print 'teenager'
else:
print 'kid'
if age >= 18:
print 'adult'
elif age >= 6:
print 'teenager'
else:
print 'kid'
2019-11-20
'a=123' and "a=111" 优先级高 返回True
True and True 当然返回True
True and True 当然返回True
2019-11-16
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2019-11-16
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k+": "+str(d.get(k))
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k+": "+str(d.get(k))
2019-11-16