【发布时间】:2016-05-04 11:30:05
【问题描述】:
我想知道如何去除所有整数和空格的输入。我知道 Python 中的 .strip() 函数可以做到这一点,但它只适用于字符串开头/结尾的字符。
这是我的代码:
battery = input("Is the phone charger turned on at the plug?").lower()
if battery == "y" or battery == "yes":
print("Replace the phone's battery or contact the phone's manufacturer.")
break
所以如果用户输入'ye2s',程序会去掉'2'并把它当作'yes'。
【问题讨论】:
标签: python python-3.x python-3.4 python-3.3