如何创建菜单或目录? [英] How to create a menu or directory?

查看:111
本文介绍了如何创建菜单或目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Python制作简单的菜单/目录?我想要有一些用户会按照要求执行任务的信件,当他们在提示后输入信件时,完成任务,例如:

How do I make a simple Menu/Directory using Python? I would like to have letters that the user would press to do tasks, and when they enter the letter after the prompt, the task is done... for example:

一个。创建用户名

B.编辑用户名

C.退出

A. Create Username
B. Edit Username
C. Exit

选择:

然后所有的用户必须输入提示后的一个字母。

And then all the user has to do is enter one of the letters after the prompt.

推荐答案

A(非常)基本的方法将是这样的:

A (very) basic approach would be something like this:

print "A. Create Username"
print "B. Edit Username"
input = raw_input("Enter your choice")

if input == "A":
    print "A was given" 
if input == "B":
    print "B was given"

这篇关于如何创建菜单或目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆