【发布时间】:2016-07-27 12:01:49
【问题描述】:
我已经在 python 中完成了这个。当我插入一个单词时,它会在一个数字后重复 例如,如果我插入堆栈,它将打印:
stack 1
stack 2
stack 3
stack 4
stack 5
stack 6
stack 7
stack 8
stack 9
我希望 python 打印文件文本中的名称和数字。我搜索但没有找到任何东西。
代码:
pwd=raw_input("Enter a word:")
n=0
n=str(n)
print (pwd,n)
while n<9:
out_file=open("tesxt.txt","w")
n+=1
out_file.write(pwd)
out_file.write(n)
out_file.close()
我希望 python 编写从循环生成的单词。 谢谢帮忙
【问题讨论】:
标签: python python-2.7 loops python-3.x while-loop