因为某些简单的字符串判断的需要,所以记录下。 运行环境 Runtime environment123操作系统 : Windows10IDE: JetBrains Python 2019.2.4 x64语言: Pytthon 3.68 代码实例123456789101112# 判断是否是全数字:str.encode('UTF-8').isdigit()# 判断是否是全英文:str.encode('UTF-8').isalpha()print "孙".encode('UTF-8').isdigit()print "孙".encode('UTF-8').isalpha()print '123few'.encode('UTF-8').isdigit()print '123few'.encode('UTF-8').isalpha()print '123'.encode('UTF-8').isdigit()print 'few'.encode('UTF-8').isalpha()