2
我的代碼是:蟒蛇3無法寫入文件
from random import randrange, choice
from string import ascii_lowercase as lc
from sys import maxsize
from time import ctime
tlds = ('com', 'edu', 'net', 'org', 'gov')
for i in range(randrange(5, 11)):
dtint = randrange(maxsize)
dtstr = ctime()
llen = randrange(4, 8)
login = ''.join(choice(lc)for j in range(llen))
dlen = randrange(llen, 13)
dom = ''.join(choice(lc) for j in range(dlen))
print('%s::%[email protected]%s.%s::%d-%d-%d' % (dtstr, login,dom, choice(tlds),
dtint, llen, dlen), file='redata.txt')
我想打印在一個文本文件中的結果,但我得到這個錯誤:
dtint, llen, dlen), file='redata.txt')
AttributeError: 'str' object has no attribute 'write'