私はPythonの初心者であり、この単純なコードを記述しましたが、解決できなかったエラーがいくつかあります:(
誰か助けてもらえますか?
//initialization
str = None
var = None
def setvar(val):
""" Sets the global variable "var" to the value in 'val' """
if val:
print "setting variable 'var' to '$val'" // we want to print the value of 'val'
else:
print "un-setting variable 'var'"
var = val
return
if __name__ == 'main':
try:
setvar(" hello world! ") // use this function to set the 'var' variable
var.strip() // we want the leading and trailing spaces removed
print str(var)
except:
print "something went wrong"