python字符串isalnum方法可以判断字符串是否只包含字母和数字,如果字符串不是空串,且只包含字母和数字,该方法返回True,反之返回False
word = 'hello23'
print(word.isalnum())  # True
word = 'hello word'
print(word.isalnum())  # False
 
            扫描关注, 与我技术互动
QQ交流群: 211426309
 
                        分享日常研究的python技术和遇到的问题及解决方案