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 –