# -*- coding: utf-8 -*-
import hashlib 
import time
import sys
filename = sys.argv[1]
partsize = int(sys.argv[2])
prefix = sys.argv[3]

print("split file...")

partn = 0
# 读取文件
data = ""
with open(filename, 'r') as f:
    for line in f:
        data = data+line
              
        if len(data)> partsize:
            tmpdata = data[0:partsize]
            partn = partn+1
            with open(prefix+str(partn), 'wb') as f:
                f.write(tmpdata)

            print("part_"+str(partn)+" : ", partsize)
            data=data[partsize:]

if len(data) > 0:
    partn = partn+1
    with open(prefix+str(partn), 'wb') as f:
        f.write(data)
        print("part_"+str(partn)+" : ", len(data))
        data=data[partsize:]