Python: TypeError: a float is required

المشرف العام

Administrator
طاقم الإدارة
I have a python script with some parameters - see screen.


You see the last parameter is of type Double, default Value 0.

The code i have this:

Ausrichtung = float(arcpy.GetParameterAsText(9))if Ausrichtung == '#' or not Ausrichtung: Ausrichtung = "0.0"# maybe there is some useless ballast...it comes from an export from modelbuilder, and I am learning python now.arcpy.AddMessage("Ausrichtung"+ Ausrichtung)SteigungX = -math.sin(math.radians(Ausrichtung))1) When I start the script - in the form i let for this parameter a 0, i always get:Ausrichtung0.0TypeError: a float is required2) If I start the schript - with this parameter as a 5, it works.3) When I replace last line with SteigungX = -math.sin(math.radians(float(Ausrichtung))) it works with all values, also with 0

I have several more parameters before this, an I can calculate with them. Why is Zero so different? Why do I have Ausrichtung in case 1) a 0, even when I use this float function? AddMessage give a 0.0, so why still not recognized as float?

Thank you for Ideas!



أكثر...
 
أعلى