用Python写TXT复读机
主要的函数
with open (str(文件名(绝对路径), ‘w’ ) as 自定义名称:
w》写
r》读
a》插入
自定义名称.方法(str(内容))
"""
text.py
"""
filepath = "C:/" #修改
fileend = ".txt"
content = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" \
"2333333" \
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
############################################
i = 10000 #文件个数
j = 100 #复读行数
############################################
for x in range(i):
filename = filepath + str(x) + fileend
with open(filename, 'w') as f:
for y in range(j):
f.write(content)