【发布时间】:2017-06-08 14:15:24
【问题描述】:
有没有办法使用 python 连续向文本文件添加随机坐标? (更新)
import random
import threading
#Open a file named numbersmake.txt.
outfile = open('new.txt', 'w')
def coordinate():
threading.Timer(0.0000000000001, coordinate).start ()
x = random.randint(0,10000)
y = random.randint(0,10000)
outfile.write("{},{}\n".format(x, y))
coordinate()
#Close the file.
outfile.close()
print('The data is now the the new.txt file')
【问题讨论】:
标签: python-3.x real-time text-extraction