我才刚刚开始我只是不确定如何将数字放在每行前面,并将其放在 txt 文件中。这就是我到目前为止所拥有的。
def numbered(infile, outfile): for line in infile: line = #我不知道从这里去哪里
定义主():
try:
infileName = input("Enter the file holding the poem:")
infile = open(infileName,"r")
outfileName = input("Enter the file name to hold the numbered poem:")
outfile = open(outfileName,"w")
print("Numbered version of" + infileName + "is here in" + outfileName +)
except IOError:
print ("Error, could not find files")
主要的()
最终结果应该是第一行诗行第二诗行诗第三行等
成: 1. 诗的第一行 2. 诗的第二行 3. 诗的第三行 等