您好,登錄后才能下訂單哦!
例子:
1:www.jb51.net
2:www.jb51.net
3:www.jb51.net
4:www.jb51.net
5:www.jb51.net
6:www.jb51.net
7:www.jb51.net
8:www.jb51.net
9:www.jb51.net
10:www.jb51.net
11:www.jb51.net
12:www.jb51.net
13:www.jb51.net
14:www.jb51.net
15:www.jb51.net
16:www.jb51.net
python函數(shù)代碼
# -*- coding: utf-8 -*- ''' python讀取文件,偶數(shù)行輸出一個文件,奇數(shù)行輸出一個文件 ''' 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中%代表什么意思
求模運算,相當(dāng)于mod,也就是計算除法的余數(shù),比如5%3就得到2。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。