展开全部
from random import randint
def main():
outfile=open("numbers.txt","w") # 打开文件写数据
for i in range(100):
outfile.write(str(randint(0,100))+" ")
outfile.close()
infile=open("numbers.txt","r") #打开文件读数据
s=infile.read()
numbers=[eval(x) for x in s.split()] #字符间用空白符分隔
for number in numbers:
print(number, end=" ")
infile.close()
main()
def main():
outfile=open("numbers.txt","w") # 打开文件写数据
for i in range(100):
outfile.write(str(randint(0,100))+" ")
outfile.close()
infile=open("numbers.txt","r") #打开文件读数据
s=infile.read()
numbers=[eval(x) for x in s.split()] #字符间用空白符分隔
for number in numbers:
print(number, end=" ")
infile.close()
main()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询