String模块包括的字符串
- 我们先来看看原始string模块有包含哪些数据?
- ascii_lowercase = ‘abcdefghijklmnopqrstuvwxyz’;
- ascii_uppercase = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’
- digits = ‘0123456789’
- punctuation = r"""!"#$%&’()*+,-./:;<=>?@[]^_`{|}~"""
- hexdigits = digits + ‘abcdef’ + ‘ABCDEF’
- printable = digits + ascii_letters + punctuation + whitespace(这是包括所有字符串)
import _string
whitespace = ' \t\n\r\v\f'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'
punctuation = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
printable = digits + ascii_letters + punctuation + whitespace
使用String的字符串,随机选择提取想要的数据组合
- 注意:手机号段,phone_start只复制了部分,若需所有,可与三大运营商确认精确号段;
- 使用string.digits,获取8位手机尾号
- ascii_uppercase+digits 从大写字母和数字中随机选择5位车牌尾号
import random