生成随机数字列表
import random
n=[]
for i in range(100):
a=random.randint(1,100)
n.append(a)
生成连续数字列表
n=[i for i in range(1,101)]
数字形式写入文件shuchu(空格分隔)
with open("shuchu.txt","w") as file:
file.write(" ".join(map(str,n)))
数字形式写入文件shuchu(每行一个)
with open("shuchu2.txt","w") as file:
file.write("\n".join(map(str,n)))