用allowlist或blocklist装饰命令行界面并简化复杂的用户输入。

monoprompt的Python项目详细描述


单挑

用allowlist或blocklist装饰命令行界面并简化复杂的用户输入。在

安装

pip install monoprompt

使用

1。导入

^{pr2}$

2。询问用户的输入。

# basic usageask("What is your name? ")# removes extra charactersask("What is your age? ",chars="3")# allows empty inputask("Where do you live? ",once=True)

3。请求输入并与允许值进行比较。

# basic usagerequest("Choose a number? ",("1","2","0"))# allows only to choose between Apple, Banana, and Cherry, and never Durianrequest("Select? ",("Apple","Banana","Cherry"),blocklist=("Durian"))# allows empty inputrequest("Select? ",("Apple","Banana","Cherry",""),blocklist=("Durian"))

4。用任何字符装饰线条。

# fills the whole console line with the specified characterdecorate("#")# limits only to 50 characters in lengthdecorate("#",chars=50)# fills the whole console line with the specified word, up to the max limitdecorate("hello")# fills the whole console line with the specified word, up to a hundred charactersdecorate("hello",100)

^{str 1}5美元。将消息打印到控制台。

# basic usagemessage(string)# centers message in consolemessage(string,centered=True)# centers message in a 50-character lengthmessage(string,chars=50,centered=True)# padds a string to the leading and trailing ends of the messagemessage(string,padding="#",centered=True)# fills the leading and trailing white spaces with the specified charactermessage(string,chars=0,fill="-",centered=True)

6。打印已排序的列表。

# basic usagecatalog(("Apple","Banana","Cherries"))# orselection=("Apple","Banana","Cherries")catalog(selection)

7。获取列表的索引。

# basic usageindices=keys(("Apple","Banana","Cherries"))# extend listindices=keys(("Apple","Banana","Cherries"),extend=["x"])

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将cassandra中的行数据转换为与列相关的嵌套json   java如何使用jcr XPath在jcr:content/@jcr:data中搜索?   java在使用openCV进行安卓开发时如何利用手机的广角镜头   java解析扩展了接口,结束了一个潜在的无限循环   位置服务的@Override方法中存在java Android应用程序错误   java本地线程的用途和需求是什么   具有左右子访问的java节点树遍历   java验证JsonWebToken签名   JUL日志处理程序中的java日志记录   嵌入式Java读取给定时间段的串行数据。   java有没有办法从多个URL获取多个图像?   java线程通过等待intent阻止自己发送intent   java Spring MVC解析多部分内容请求   java JPA/Hibernate静态元模型属性未填充NullPointerException   java格式错误的字符(需要引号,得到I)~正在处理   java为什么PrintWriter对象抛出FileNotFoundException?   java Neo4j未正确保存标签   java IE不加载图像