简体   繁体   中英

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:

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. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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