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

因为某些简单的字符串判断的需要,所以记录下。

运行环境 Runtime environment

1
2
3
操作系统 : Windows10
IDE: JetBrains Python 2019.2.4 x64
语言: Pytthon 3.68

代码实例

1
2
3
4
5
6
7
8
9
10
11
12
# 判断是否是全数字:
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()

×

也就放着玩的

扫码支持
扫码打赏,其实感觉也没人会给的。。

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 运行环境 Runtime environment
  • 代码实例
  • ,