try:
print p.__score
except Exception, e:
print Exception, e
print("我要过关")
print "attributeerror"
print p.__score
except Exception, e:
print Exception, e
print("我要过关")
print "attributeerror"
2016-06-11
import math
def is_sqr(x):
return math.sqrt(x).is_integer()
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x).is_integer()
print filter(is_sqr, range(1, 101))
2016-06-11
def count():
fs = []
for i in range(1, 4):
num = i*i
def f(m=num):
def ff():
return m
return ff
fs.append(f(num))
return fs
f1, f2, f3 = count()
print f1(), f2(), f3()
正解。
fs = []
for i in range(1, 4):
num = i*i
def f(m=num):
def ff():
return m
return ff
fs.append(f(num))
return fs
f1, f2, f3 = count()
print f1(), f2(), f3()
正解。
2016-06-11
str.capitalize()
Return a copy of the string with its first character capitalized and the rest lowercased.
For 8-bit strings, this method is locale-dependent.
Return a copy of the string with its first character capitalized and the rest lowercased.
For 8-bit strings, this method is locale-dependent.
2016-06-11
对time模块和我一样懵逼的可以看看这个博客,讲得很清楚了。 http://blog.csdn.net/kiki113/article/details/4033017
2016-06-11
我的可能是最最麻烦的算法了:
def format(s):
out=s[0].upper()
b=1
c=len(s)
while True:
out=out+s[b].lower()
b=b+1
if b==len(s):
break
return out
def format(s):
out=s[0].upper()
b=1
c=len(s)
while True:
out=out+s[b].lower()
b=b+1
if b==len(s):
break
return out
2016-06-10
def calc_prod(lst):
def j():
y = 1
for x in lst:
y = x * y
return y
return j
def j():
y = 1
for x in lst:
y = x * y
return y
return j
2016-06-08
def cmp_ignore_case(s1, s2):
s1 = s1.lower()
s2 = s2.lower()
if s1 > s2:
return 1
elif s1 < s2:
return -1
return 0
s1 = s1.lower()
s2 = s2.lower()
if s1 > s2:
return 1
elif s1 < s2:
return -1
return 0
2016-06-08