授人以渔,不如先给人鱼
PHP 代码:
# -*- coding:utf-8 -*-
import sys
if len(sys.argv) < 5:
print("use: python3 this_file [input_file] [output_file] [begin] [length]")
exit()
input_file = sys.argv[1]
output_file = sys.argv[2]
begin = int(sys.argv[3])
length = int(sys.argv[4])
with open(output_file, 'ab') as out:
with open(input_file, 'rb') as f:
f.seek(begin)
out.write(f.read(length))
out.write(bytes("\n", encoding='ascii'))
print("done")
注意: 要用Python3
~~呵呵~~