0
我在Python中有一個由多個函數列表組成的腳本,並且在列表的每一端我都要放置一個後退函數,讓我返回到腳本的開頭並選擇另一個列表。例如:如何返回到python腳本的頂部?
list = ("1. List of all users",
"2. List of all groups",
"3. Reset password",
"4. Create new user",
"5. Create new group",
"6. List all kernel drivers",
"7. List all mounts",
"8. Mount a folder",
"9. Exit")
for i in list:
print(i)
如果我選擇1另一個列表打開:
list = "1) Show user Groups \n2) Show user ID \n3) Show user aliases \n4) Add new aliases \n5) Change password \n6) Back"
print
print list
更具體的例子。
使用某種循環。你可以在這裏學習如何做到這一點:http://www.tutorialspoint.com/python/python_while_loop.htm –