【发布时间】:2015-02-13 12:57:12
【问题描述】:
我的无限 while 循环没有像我预期的那样工作:
def main():
print("Type 1 to create a file")
print("Type 2 to read a file")
print("Type 3 to append a file")
print("Type 4 to calculate total of file")
print("Type 5 to end the program")
choice=input("Select a number:")
if choice == '1':
file_create(filename)
elif choice == '2':
read_file(filename)
elif choice == '3':
append_file(filename)
elif choice == '4':
add_numbers(filename)
filename=input("Give a name to your file:")
while main():
# ...
这会执行一次main,但不会循环。
【问题讨论】:
标签: python function loops while-loop