Python如何用文件操作把执行结果保存到文件里?
f=open("lianxi2.txt",'wb')f.write(print'useno:'k=0while(k<10):useno=''.join(random.sa...
f = open("lianxi2.txt",'wb')
f.write(
print 'useno:'
k=0
while (k<10):
useno = ''.join(random.sample('qwertyuiopasdfghjklzxcvbnm1234567890',8))
print useno
k = k+1
print '-------------------------------------------------------'
print 'usepsw:'
h=0
while (h<10):
usepsw = ''.join(random.sample('qwertyuiopasdfghjklzxcvbnm1234567890',8))
print usepsw
h = h+1
)
f.close()
这段代码是报错的,我想1.新建文件、2.写入结果。3.关闭。。。请问怎么写才是正确的语法 展开
f.write(
print 'useno:'
k=0
while (k<10):
useno = ''.join(random.sample('qwertyuiopasdfghjklzxcvbnm1234567890',8))
print useno
k = k+1
print '-------------------------------------------------------'
print 'usepsw:'
h=0
while (h<10):
usepsw = ''.join(random.sample('qwertyuiopasdfghjklzxcvbnm1234567890',8))
print usepsw
h = h+1
)
f.close()
这段代码是报错的,我想1.新建文件、2.写入结果。3.关闭。。。请问怎么写才是正确的语法 展开
2个回答
展开全部
f = open("lianxi2.txt",'wb')
print >>f, 'useno:'
k=0
while (k<10):
useno = ''.join(random.sample('qwertyuiopasdfghjklzxcvbnm1234567890',8))
print >>f, useno
k = k+1
print >>f, '-------------------------------------------------------'
print >>f, 'usepsw:'
h=0
while (h<10):
usepsw = ''.join(random.sample('qwertyuiopasdfghjklzxcvbnm1234567890',8))
print >>f, usepsw
h = h+1
f.close()
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询