Python判断是否纯数字或者英文

判断是否是全数字:
        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()

你可能感兴趣的:(Python判断是否纯数字或者英文)