铁蟒缩进错误

时间:2015-05-08 09:31:15

标签: 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

我收到错误

  

&#39; flucommands = flucommands +&#34; PorositySub&#34; + countt&#39;错误是期望的   缩进块&#39;

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

1 个答案:

答案 0 :(得分:3)

这需要缩进:

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