Python--random,String随机获取数据

String模块包括的字符串

  • 我们先来看看原始string模块有包含哪些数据?
  • ascii_lowercase = ‘abcdefghijklmnopqrstuvwxyz’;
  • ascii_uppercase = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’
  • digits = ‘0123456789’
  • punctuation = r"""!"#$%&’()*+,-./:;<=>?@[]^_`{|}~"""
  • hexdigits = digits + ‘abcdef’ + ‘ABCDEF’
  • printable = digits + ascii_letters + punctuation + whitespace(这是包括所有字符串)
import _string

# Some strings for ctype-style character classification
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

# Functions which aren't available as string methods.

使用String的字符串,随机选择提取想要的数据组合

  • 注意:手机号段,phone_start只复制了部分,若需所有,可与三大运营商确认精确号段;
  • 使用string.digits,获取8位手机尾号
  • ascii_uppercase+digits 从大写字母和数字中随机选择5位车牌尾号
import random
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值