-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaima2.txt
51 lines (37 loc) · 1.39 KB
/
daima2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
# -*- coding:utf-8 -*-
from datetime import datetime
def Main():
source_dir = 'C:/Users/29459/Desktop/word/words.txt'
target_dir = 'C:/Users/29459/Desktop/word/out/'
# 计数器
flag = 0
# 文件名
name = 1
# 存放数据
dataList = []
print("开始。。。。。")
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
with open(source_dir, 'r') as f_source:
for line in f_source:
flag += 1
dataList.append(line)
if flag == 1572:
with open(target_dir + "xbf" + str(name) + ".txt", 'w+') as f_target:
for data in dataList:
f_target.write(data)
name += 1
flag = 0
dataList = []
# 处理最后一批行数少于200万行的
# with open(target_dir + "xbf" + str(name) + ".txt", 'w+') as f_target:
# for data in dataList:
# f_target.write(data)
print("完成。。。。。")
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
Main()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/