例子:
1:www.vevb.com
2:www.vevb.com
3:www.vevb.com
4:www.vevb.com
5:www.vevb.com
6:www.vevb.com
7:www.vevb.com
8:www.vevb.com
9:www.vevb.com
10:www.vevb.com
11:www.vevb.com
12:www.vevb.com
13:www.vevb.com
14:www.vevb.com
15:www.vevb.com
16:www.vevb.com
python函数代码
# -*- coding: utf-8 -*-'''python读取文件,偶数行输出一个文件,奇数行输出一个文件'''def fenhang(infile,outfile,outfile1): infopen = open(infile,'r',encoding='utf-8') outopen = open(outfile,'w',encoding='utf-8') outopen1 = open(outfile1, 'w', encoding='utf-8') lines = infopen.readlines() i = 0 for line in lines: i += 1 if i % 2 == 0: outopen.write(line) else: outopen1.write(line) infopen.close() outopen.close()fenhang("jb51.txt","oushu.txt","jishu.txt")
效果图
python中%代表什么意思
求模运算,相当于mod,也就是计算除法的余数,比如5%3就得到2。
新闻热点
疑难解答