python3 生成随机数
#!/usr/bin/env python# encoding: utf-8# @Time: 2019/5/21 22:13# @Author: ZengChenyu# @Site:# @File: test.py# @Software: PyCharmfrom random import randintf = open("data.txt", 'w...
·
#!/usr/bin/env python
# encoding: utf-8
# @Time : 2019/5/21 22:13
# @Author : ZengChenyu
# @Site :
# @File : test.py
# @Software: PyCharm
from random import randint
f = open("data.txt", 'w') #输出到文件
#for i in range(0, 10):
i = 0
while i < 10:
i += 1
ch = chr(randint(0, 25) + 65) #randint生成闭区间整形随机数 chr生成的随机数转ASCII字符
print(ch, end="", file=f) #end输出的结尾不空格或者是换行
f.close()
更多推荐
已为社区贡献1条内容
所有评论(0)