简体   繁体   English

Python错误:未定义全局名称d

[英]Python Error: Global Name d not Defined

I keep getting this error "Python Error: Global Name not Defined" although I used the same expression before in my code and it worked: 我一直收到此错误“ Python错误:全局名称未定义”,尽管我之前在代码中使用了相同的表达式,但仍然有效:

if (toggle_tau == 1):
            ensight.part.select_byname_begin("(CASE:Case 1)Hole %d Clip #%d"%(selected_hole+1,i+1))
            ensight.variables.evaluate("Hole%d_Tau_Clip%d = ACOS((U*Hole%d_uMassFluxAvg%d+V*Hole%d_vMassFluxAvg%d+W*Hole%d_wMassFluxAvg%d)/(SQRT(U^2+V^2+W^2+1e-15)*SQRT(Hole%d_uMassFluxAvg%d^2+Hole%d_vMassFluxAvg%d^2+Hole%d_wMassFluxAvg%d^2+1e-15)))*nHeptane_Volume_Fraction*180/PI"%d(selected_hole+1,i+1,selected_hole+1,i+1,selected_hole+1,i+1,selected_hole+1,i+1,selected_hole+1,i+1,selected_hole+1,i+1,selected_hole+1,i+1))

For the last line it tells me that global name d is not defined. 对于最后一行,它告诉我未定义全局名称d。 I don't get it because for other parts of the code where I evaluated other variables in the same way it was working... 我不明白这一点,因为对于代码的其他部分,我以相同的方式评估其他变量...

Right here is the problem: 问题就在这里:

"[...]Volume_Fraction*180/PI"%d(selected_hole[...]

I believe the %d should be inside the quote and you're missing the percentage symbol: 我相信%d应该在引号内,并且您缺少百分比符号:

"[...]Volume_Fraction*180/PI%d"%(selected_hole[...]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM