我有一个小python脚本,它将返回范围(1,36)的所有7个组合,并将其写入txt文件。在
from itertools import combinations
f = open('combinations.txt', 'w')
for comb in combinations(range(1,36), 7):
f.write(str(comb))
f.write('\n')
f.close()
但因为这会是一个非常大的文件,我不想写那些7,6,5连续数字。在
例如:
你知道我怎么做吗?我的txt有多大?在
这会让你上路:
如果我没搞错,你可以这样做:
它节省了6724520中的12615,相当于0.18%,结果是180.5 MB的文件。在
我有点小问题。txt文件太小,无法存储这样的数据,所以我决定使用数据库。但是在我的新代码之后,我收到了一条错误消息:
相关问题 更多 >
编程相关推荐