def firstCharUpper(s):
return s[0:1].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0:1].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2016-05-27
def average(*args):
sum = 0.0
#t统计args长度
t = 0
for i in args:
sum += i
t += 1
if t == 0:
return 0.0
else:
return sum/t
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
#t统计args长度
t = 0
for i in args:
sum += i
t += 1
if t == 0:
return 0.0
else:
return sum/t
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2016-05-27
答案太水了吧。。。只有一对‘’和“”,为啥要用\转义字符
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
2016-05-27
s = '123456789'
m = '0123456789'
print [int(a + b + c) for a in s for b in m for c in m if a == c]
字符串不要紧,强转就行
m = '0123456789'
print [int(a + b + c) for a in s for b in m for c in m if a == c]
字符串不要紧,强转就行
2016-05-27
strs = 'abcdefgh'
strs[:1].upper()+strs[1:]
'Abcdefgh'
strs[:1].upper()+strs[1:]
'Abcdefgh'
2016-05-27