Example:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
python function code
# -*- coding: utf-8 -*- ''' Python reads a file and outputs one file on even lines and one file on odd lines ''' 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 = () i = 0 for line in lines: i += 1 if i % 2 == 0: (line) else: (line) () () fenhang("","","")
rendering (visual representation of how things will turn out)
What does % mean in python?
The modulus operation, equivalent to mod, is the calculation of the remainder of a division, e.g. 5% 3 gives 2.