L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop()
print L # ==>['Adam','Lisa']
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.append('shit')
L.pop()
L.pop()
L.pop(2)
print L
L.pop()
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop()
print L # ==>['Adam','Lisa']
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop(2)
print L
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.append('shit')
L.pop()
L.pop()
L.pop(2)
print L
2015-11-26
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L # ==>['Adam','Lisa']
L.pop(2)
L.pop()
print L # ==>['Adam','Lisa']
2015-11-26
L = ['Adam', 'Lisa', 'Bart']
L.insert(0,'Paul')
print L
即可
L.insert(0,'Paul')
print L
即可
2015-11-25
L = ['Adam', 95.5, 'Lisa', 89, 'Bart', 59]
print 'L=',L
print 'L=',L
2015-11-25
a = 'python'
print 'hello,',a or 'world' # ==>hello,python
b = ' '
print 'hello,',b or 'world' # ==>hello, /*空格*/
c = ''
print 'hello,',c or 'world' # ==>hello,world
print 'hello,',a or 'world' # ==>hello,python
b = ' '
print 'hello,',b or 'world' # ==>hello, /*空格*/
c = ''
print 'hello,',c or 'world' # ==>hello,world
2015-11-25
和数学运算不同的地方是,Python的证书运算结果仍然是整数,浮点数运算结果仍然是浮点数。
print 2.5 + 10.0 / 4
print 2.5 + 10.0 / 4
2015-11-25
# coding=utf-8
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
s = 0.0
for i in d.itervalues():
s += i
print s/len(d)
# 直接计算
print float(sum(d.values()))/len(d)
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
s = 0.0
for i in d.itervalues():
s += i
print s/len(d)
# 直接计算
print float(sum(d.values()))/len(d)
2015-11-25
答案不对!
def move(n,a,b,c):
if n == 1:
print a,'-->',c
return
else:
print a,'-->',b
move(n-1,a,b,c)
print b,'-->',c
def move(n,a,b,c):
if n == 1:
print a,'-->',c
return
else:
print a,'-->',b
move(n-1,a,b,c)
print b,'-->',c
2015-11-24
方法一:第一行:# coding=utf-8
接着: print ur'''静夜思
床前明月光,
疑似地上斑。
举头望幽处,
低头思井空。'''
方法二:#coding=utf8
s = u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print s
接着: print ur'''静夜思
床前明月光,
疑似地上斑。
举头望幽处,
低头思井空。'''
方法二:#coding=utf8
s = u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print s
2015-11-24
print r'''
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
我是看了下面才顿悟的,大伙儿看我下面。。。
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
我是看了下面才顿悟的,大伙儿看我下面。。。
2015-11-24
s = 'Python was started in1989 by "Guido".'
b = 'Python is free and easy to learn'
print s,b
b = 'Python is free and easy to learn'
print s,b
2015-11-24