即时函数试图在if语句里面调用函数,但它不起作用。这是我第一次尝试使用Python。我究竟做错了什么?if语句里面的调用函数
#!/usr/bin/python
menu = raw_input ("Hello, please choose form following options (1,2,3) and press enter:\n"
"Option 1\n"
"Option 2\n"
"Option 3\n")
if menu == str("1"):
savinginfile = raw_input ("Please, state your name: ")
option1()
elif menu == str("2"):
print ("Option 2")
elif menu == str("3"):
print ("Option 3")
def option1():
test = open ("test.txt", "rw")
test.write(savinginfile)
print ("Option 1 used")
test.close()
什么不行?你得到一个错误代码?请详细说明。 – jramirez