发布时间:2019-09-05 07:02:05编辑:auto阅读(1526)
1.计算闰年:
def runnian(i):
if((i%4==0 and i%100!=0) or i%400==0):
return True
else:
return False
i = int(raw_input ('year: \n'))
print runnian(i)
2.质数:
#!/usr/bin/python
num=[];
i=2
for i in range(2,100):
j=2
for j in range(2,i):
if(i%j==0):
break
else:
num.append(i)
print(num)
读写文件:
#--coding:utf-8
f=open('a.txt','w+')
f.write("hello\n")
a=f.tell()
print a
f=open('a.txt','a')
f.close
f=open('a.txt','a+')
#f.seek(0)
b=f.read(4)
print b
f.close
上一篇: python中词典的values值的修改
下一篇: python学习(13)
47864
46428
37315
34762
29333
25991
24946
19968
19566
18052
5807°
6434°
5949°
5976°
7081°
5927°
5965°
6456°
6421°
7801°