該圖書館仍在發展進度。如果您找到了一個錯誤,請在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 :)。