无论我尝试过什么,我都会遇到这个错误。我尝试使用edf(edf_size)和int(edf_size)。
Traceback (most recent call last):
enter code hereFile "C:/Users/Joshua/PycharmProjects/Plane Maker/main.py", line 229, in <module>
file.write("The EDF Thrust Tube is "+ edf() + " inches.\n")
TypeError: 'str' object is not callable
它对应于这两部分代码:
edf_size = int(input("Enter the edf size, only the number portion in mm (like 64): "))
character = input("Do you want a plane with speed, power, or both? ")
while True:
if (character == "speed"): break
if (character == "power"): break
if (character == "both"): break
file.write("The EDF size is "+ str(edf_size) + " mm.\n")
file.write("The EDF Thrust Tube is "+ edf() + " inches.\n")
和
#Set edf tube length
def edf():
global edf_size
thrust_tube = (edf_size * 25.4) * 4
return str(thrust_tube)
。 。 。 请帮助我,我真的不知道为什么它不起作用。
答案 0 :(得分:0)
您需要使用Global吗?
你能试试吗?
'import the text file into a string
Function DownloadTextFile(URL As String) As String
On Error GoTo Err_GetFromWebpage
Dim objWeb As Object
Dim strXML As String
' Instantiate an instance of the web object
Set objWeb = CreateObject("Msxml2.ServerXMLHTTP")
' Pass the URL to the web object
objWeb.Open "GET", URL, False
'don't cache the file
objWeb.setRequestHeader "Content-Type", "text/xml"
objWeb.setRequestHeader "Cache-Control", "no-cache"
objWeb.setRequestHeader "Pragma", "no-cache"
'send the request
objWeb.send
' Look at the HTML string returned
strXML = objWeb.responseText
DownloadTextFile = strXML
End_GetFromWebpage:
' Clean up after ourselves!
Set objWeb = Nothing
Exit Function
Err_GetFromWebpage:
' Just in case there's an error!
MsgBox Err.Description & " (" & Err.Number & ")"
Resume End_GetFromWebpage
End Function
你还确定你没有在你的代码中的某个地方重新定义edf作为字符串吗?