我想在另一個函數中調用一個函數。它是如何完成的?如何在另一個函數中調用函數?
#=========#=========#=========#=========#
def text_file():
filename = 'text.txt'
return filename
#=========#=========#=========#=========#
def show_log(): ## Main log function,
#filename = 'text.txt'
if not os.path.exists(text_file()): # if text.txt does not exists than create one
file(text_file(), 'w').close()
if os.path.getsize(text_file()) > 0: # if text.txt is not empty show the menu
log_menu()
else: # if text.txt is empty
print
print " You have not draw anything yet!"
print
raw_input(' Press Enter to continue ')
return
我不明白你的問題是什麼。你能更精確嗎? – 2012-01-18 13:45:17
可以工作,但在show_log()開頭調用一次可能會更有效,並將其分配給本地變量。 – Gerrat 2012-01-18 13:46:22
http://docs.python.org/tutorial/controlflow.html#defining-functions – 2012-01-18 13:46:32