以下 Python 代码使用循环和文件写入操作,生成 1000 个文本文件,每个文件包含 100,000 个 '111111111111' 字符串。

import os
import time

for i in range(1000):
    with open('s/%d.txt' % i, 'w', encoding='utf-8') as f:
        f.write('111111111111' * 100000)
        print('
已经完成{}%!'.format(int((i + 1) / 10)), end='')

time.sleep(1)
print('
完成, 筹字数,114514')

生成的文本文件存储在当前目录下的一个名为 's' 的文件夹中。


原文地址: https://www.cveoy.top/t/topic/o3nO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录