string 模块有很多有用的内容东西
比如大小写字符, 数字字符等
现在来测试一下:
import string
print string.letters #包含大小写字母
print string.ascii_letters #包含大小写字母
print string.lowercase #小写字母
print string.uppercase #大写字母
print string.punctuation #其他符号
于是就很好奇,为什么这样?
在python的安装路径里面,找到string库,即string.py
看完这个代码就明白了
# Some strings for ctype-style character classification
whitespace = ' \t\n\r\v\f'
lowercase = 'abcdefghijklmnopqrstuvwxyz'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
letters = lowercase + uppercase
ascii_lowercase = lowercase
ascii_uppercase = uppercase
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'