我想檢查用戶的輸入是否只包含字母。其他論壇看起來像'isalpha'功能似乎是我正在尋找,但是當我在我的代碼中使用它並運行它時,出現一個錯誤,說AttributeError: 'str' object has no attribute 'isalpha'
。如何檢查一個字符串是否只有使用isalpha的python中的字母?
這是我的代碼:
name='hello'
if name.isalpha():
print("Your name is valid")
我不明白我要去哪裏錯了。
它[絕對存在](https://docs.python.org/3/library/stdtypes.html#str.isalpha)。 – jonrsharpe
你的Python版本有多大? – twalberg
你的python intepreter的版本是什麼。 – HuStmpHrrr