【发布时间】:2016-06-01 15:04:08
【问题描述】:
每当我尝试使用我的 python 程序读取文件时,在命令停止之前我只会得到一行。我很确定它与print(line) 有关,但我不知道任何其他选择。到目前为止,这是我所拥有的:
def fopen():
file = input("Open: ")
print("")
with open(file, 'r') as f:
for line in f:
print(line)
print("")
editredirect()
def editredirect():
print("You can edit this file with the 'edit' command.")
dcmdLvl2()
dcmdLcl2() 只是为了让我回到我的命令行。
【问题讨论】:
-
我看不出有什么问题。
dcmdLvl2是做什么的? -
editredirect()是做什么的? -
我认为您需要取消缩进
editredirect()以与with对齐