# -*- coding: -*- import io LIMIT = 150000 file_count = 0 url_list = [] with io.open('D:\DB_NEW_bak\DB_NEW_20171009_bak.sql','r',encoding='utf-16') as... ...
# -*- coding: <encoding name> -*- import io LIMIT = 150000 file_count = 0 url_list = [] with io.open('D:\DB_NEW_bak\DB_NEW_20171009_bak.sql','r',encoding='utf-16') as f: for line in f: url_list.append(line) if len(url_list) < LIMIT: continue file_name = str(file_count)+".sql" with io.open(file_name,'w',encoding='utf-16') as file: for url in url_list[:-1]: file.write(url) file.write(url_list[-1].strip()) url_list=[] file_count+=1 if url_list: file_name = str(file_count) + ".sql" with io.open(file_name,'w',encoding='utf-16') as file: for url in url_list: file.write(url) print('done')