该图书馆仍在发展进度。如果您找到了一个错误,请在Pysimpleinput GitHub问题上向我报告
您可以使用PIP安装Pysimpleinput或使用.WHL
pip3 install --upgrade PySimpleInput
pip3 install (PySimpleInput Wheel File).whl如果您需要最新的更新,请选择Devel分支,如果要稳定更新,请选择主要分支
import PySimpleInput
pysim = PySimpleInput.PySimpleInput()
输入()
过程_()
Process_可能喜欢输入,但仅用于处理文本
ex. filtering user input to return only numbers注意:方法输入()和process_()中的参数“选项”是相同的
本节包含Pysimpleinput中可用的所有选项
RMWHTSPC_*:
此选项将删除用户输入字符串中的所有空白
rmwhtspc_arr
注意:如果您使用此选项,则可能无法使用某些选项
它将返回数组/列表,而不是str
前任。 `o = pysimpleinput.input(“你叫什么名字?”,[“ rmwhtspc_arr”])
结果。
"Joseph Arauro" > "["Joseph", "Arauro"]"
rmwhtspc_str
它将返回str
前任。
o = pysimpleinput.input("What is your name?", ["rmwhtspc_str"])
结果。
"Joseph Arauro" -> "JosephArauro"
filter_num
此选项将过滤用户输入以仅返回数字
前任。
pysimOut = pysimpleinput.input("How old are you?", ["filternum"])
结果。 - >
"oejnzo299kwjo02" -> "29902"
Filteralph
此选项将过滤用户输入以返回字母字符
前任。
pysimOut = pysimpleinput.input("Type random string!", ["filteralph"])
结果。 - >
"hello219282839my282872name283739191is8287399turtleion" -> "hellomynameisturtleion"
passwd_input
注意:如果使用此选项,请确保您可以访问
/dev/tty.(UNIX用户)
此选项将使输入隐藏
(NO EXAMPLE)
上箱和低写
此选项将将用户输入字母更改为大写,反之亦然
前任。
pysimOut = pysimpleinput.input("What is your name?", options=["upcase/lowcase"])
结果。 - >
"gerardo martinuez firatzi" <(OR)> "GERARDO MARTINUEZ FIRATZI"
min_ [NUMBER]和max_ [NUMBER]
现在,您可以为输入设置最小/最大长度
前任。
res = pysimpleinput.input("What's your name?", options["min_8", "max_20"])
用户输入:FRED
提示会再次询问您是否没有通过要求
翻译和tr_ [COUNTRY ISOCODE]
注意:请在“选项”列表参数的末尾使用“翻译”选项
此选项将将输入转换为另一种语言,您必须在翻译选项之后添加“ tr_ [country isocode]”
支持的语言国家ISOCODE
像这样:
tr_en > translate_englishtr_de > translate_deutsch或translate_germanytr_fr > translate_french示例:(从印度尼西亚翻译到英语)前任。
tr = pysimpleinput.input("Apa makanan favorit mu?", options["translate", "tr_en"])
用户输入:“ Aku Suka Nasi Goreng”
结果。 - >
I like fried rice.
(已弃用)Valemail
此选项将验证用户的电子邮件
前任。 `pysimout = pysimpleinput.input(“键入电子邮件!”,[“ valemail”])
结果。 - >
True | False (If the string is an email it will return True otherwise False)
(已弃用)validate_phonenumber
此选项将验证用户的电话号码
前任。 `pysimout = pysimpleinput.input(“输入您的电话号码!”,[“ valphnum))
结果。 - >
PhoneNumber | Warning (If the string is a valid number it will return the number back otherwise a warning
pysim = pysimpleinput.input("What is your name?", ["rmwhtspc_str","filteralph")
感谢您在此模块上做出贡献
您可以通过分配此存储库并开始添加更多功能,优化代码和修复错误来做出贡献
- > ChangElog | 0.0.3
- > ChangElog | 0.0.3.1
- > ChangElog | 0.0.3.5
- > ChangElog | 0.0.4
- > ChangElog | 0.0.5
- > ChangElog | 0.0.5-rev2
- > ChangElog | 0.0.6
[COUNTRY ISOCODE][NUM]和max_ [NUM]这个项目是由我(乌龟)100%完成的,该项目已获得麻省理工学院许可证,请访问我的github https://github.com/turtleion
对不起,英语不好,我是印度尼西亚人btw :)。