铁蟒中的缩进错误

2024-09-30 18:15:58 发布

您现在位置:Python中文网/ 问答频道 /正文

flucommands = """
Library:
    CEL:
    &replace EXPRESSIONS:
    MassFlowRate = """

flucommands = flucommands + 0.43 + "[kg s^-1]"

flucommands = flucommands + """
Temp = """

flucommands = flucommands + 843.15 + "[K]"

counttt = 1
while (counttt<=3):
flucommands = flucommands + "PorositySub" + countt 
flucommands = flucommands + " = " + 0.75 + "\n" 
counttt = counttt + 1

我搞错了

'flucommands = flucommands + "PorositySub" + countt' error is 'expect an indented block'

感谢任何帮助。谢谢!!!在


Tags: islibraryerrortempexpressionsreplaceexpectkg
1条回答
网友
1楼 · 发布于 2024-09-30 18:15:58

这需要缩进:

while (counttt<=3):
    flucommands = flucommands + "PorositySub" + countt 
    flucommands = flucommands + " = " + 0.75 + "\n" 
    counttt = counttt + 1

python对语句块使用缩进而不是大括号(在其他一些语言中)。在

如果没有这个,您的while:循环就没有定义,因此会收到错误。在

请参见:http://www.tutorialspoint.com/python/python_while_loop.htmhttps://docs.python.org/2.3/ref/indentation.html

相关问题 更多 >