python操作
清空文件
一,
fibs = [0,1]
for i in range(10):
fibs.append(fibs[-1] + fibs[-2])
print fibs
二,
if x > 2
return fib(x-1) +fib(x-2)
else:
return 1
python 生成随机密码
1 #!/bin/bash/env python
2 #coding:utf8
3 import string,random,tab
4
5 sum = list(string.digits)
6 letter = list(string.ascii_letters)
7 #print sum,letter
8 str = sum + letter
9 #print str
10 s = " "
11 for i in range(8):
12 #print str[random.randint(0,len(str))] #根据随机生成的数字做下标 指定列表元素
13 passwdtmp = str[random.randint(0,len(str))]
14 s = s + passwdtmpf
15 s = s.strip()
16 print s
17 print len(s)
~