d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for x in d:
print "{0}: {1}".format(x,d[x])
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for x in d:
print "{0}: {1}".format(x,d[x])
2015-07-13
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
keys=('Adam','Lisa','Bart')
for key in keys:
print key,":",d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
keys=('Adam','Lisa','Bart')
for key in keys:
print key,":",d[key]
2015-07-13
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
L.pop(2)
L.pop(2)
print L
2015-07-13
def firstCharUpper(s):
if len(s)==0:
return null
return s[0:1].upper()+s[1:]
最起码也得判断下字符串是不是空吧
if len(s)==0:
return null
return s[0:1].upper()+s[1:]
最起码也得判断下字符串是不是空吧
2015-07-12
for x in range(1,10):
for y in range(10):
if x < y:
print x * 10 + y
for y in range(10):
if x < y:
print x * 10 + y
2015-07-11
print [x*100+y*10+z for x in range(1,10) for y in range(0,10) for z in range(0,10) if x == z]
2015-07-10
print '%s,%s' %('1','2')
在字符串里用%s 可以输出%格式化后的tuple元素
在字符串里用%s 可以输出%格式化后的tuple元素
2015-07-10
保存为 html.py
,
G:\pyproject>python html.py>py.html
G:\pyproject>explorer py.html
,
G:\pyproject>python html.py>py.html
G:\pyproject>explorer py.html
2015-07-10