【发布时间】:2018-04-02 15:45:42
【问题描述】:
我用writelines([name])尝试过。但是它写的单词没有任何空格,并且一个接一个。这是我的代码:`
import time
from time import sleep
import random
import secrets
import string
from threading import Thread
def run_bot():
x1 = random.choice(string.ascii_uppercase)
x2 = random.choice(string.ascii_lowercase)
x3 = random.choice(string.ascii_lowercase)
x4 = random.choice(string.ascii_lowercase)
x5 = random.choice(string.ascii_lowercase)
name = str(x1 + x2 + x3 +x4 +x5)
print(name)
f = open('names.txt', 'a')
f2 = open('namero.txt', 'a')
f2.writelines([name])
while True:
for i in range(5):
run_bot()
`
【问题讨论】:
标签: python file loops rows writing