通过循环缩进的缩进

时间:2018-02-23 04:12:35

标签: python indentation

我正在尝试运行此程序,但我的缩进是完全错误的。我不确定它们应该是什么:

import os.path

count = 1

for i in range(15):
fname = "/tmp/agent-" + str(count)+".txt"
if os.path.isfile(fname):
with open(fname, 'r') as content_file:
content = content_file.read()
print(content.rstrip())
count += 1

1 个答案:

答案 0 :(得分:2)

我的猜测:

import os.path

count = 1

for i in range(15):
    fname = "/tmp/agent-" + str(count)+".txt"
    if os.path.isfile(fname):
        with open(fname, 'r') as content_file:
            content = content_file.read()
            print(content.rstrip())
    count += 1 # maybe, maybe not