随机生成四要素

  1 import random
  2 from datetime import date
  3 from datetime import timedelta
  4
  5
  6 class fourEl():
  7
  8     def __init__(self,sex):
  9         self.sex = sex
 10
 11     def create_phone(self):
 12         # 第二个数字
 13         second = [3, 4, 5, 7, 8][random.randint(0, 4)]
 14         # 第三个数字
 15         third = {3: random.randint(0, 9),
 16                  4: [5, 7, 9][random.randint(0, 2)],
 17                  5: [i for i in range(10) if i != 4][random.randint(0, 8)],
 18                  7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)],
 19                  8: random.randint(0, 9), }[second]
 20         # 最后8位数字
 21         suffix = random.randint(9999999, 100000000)
 22         # 拼接手机号
 23         return "1{}{}{}".format(second, third, suffix)
 24
 25     def getdistrictcode(self):
 26         codelist = []
 27         # 读取地区码
 28         file = open(‘/Users/zhaodi/PycharmProjects/python3/学习/自动化测试脚本/txt文档/身份证号地址对照表.txt‘,
 29                     encoding=‘ISO-8859-1‘)
 30         lines = file.readlines()
 31         # 逐行读取
 32         for line in lines:
 33             # 如果每行中去重后不为空,并且6位数字中最后两位不为00,则添加到列表里。(最后两位为00时为省份或地级市代码)
 34             if line.lstrip().rstrip().strip() != ‘‘ and (line.lstrip().rstrip().strip())[:6][-2:] != ‘00‘:
 35                 codelist.append(line[:6])
 36         return codelist
 37
 38     def create_idcard(self):
 39         codelist = self.getdistrictcode()
 40         id = codelist[random.randint(0, len(codelist))]  # 地区项
 41         id = id + str(random.randint(1950, 1998))  # 年份项
 42         da = date.today() + timedelta(days=random.randint(1, 366))  # 月份和日期项
 43         id = id + da.strftime(‘%m%d‘)
 44         easyCode = str(random.randint(100, 300))
 45
 46         sex = self.sex
 47         if sex == ‘男‘:
 48             if int(easyCode) % 2 == 1:
 49                 easyCode = easyCode
 50             else:
 51                 easyCode = int(easyCode) + 1
 52
 53         if sex == ‘女‘:
 54             if int(easyCode) % 2 == 0:
 55                 easyCode = easyCode
 56
 57             else:
 58                 easyCode = int(easyCode) + 1
 59
 60         id = id + str(easyCode)
 61
 62         # id = id + str(random.randint(100, 300))  # 顺序号简单处理
 63
 64         i = 0
 65         count = 0
 66         weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]  # 权重项
 67         checkcode = {‘0‘: ‘1‘, ‘1‘: ‘0‘, ‘2‘: ‘X‘, ‘3‘: ‘9‘, ‘4‘: ‘8‘,
 68                      ‘5‘: ‘7‘, ‘6‘: ‘6‘, ‘7‘: ‘5‘, ‘8‘: ‘5‘, ‘9‘: ‘3‘, ‘10‘: ‘2‘}  # 校验码映射
 69         for i in range(0, len(id)):
 70             count = count + int(id[i]) * weight[i]
 71         id = id + checkcode[str(count % 11)]  # 算出校验码
 72         return id
 73
 74     def create_name(self):
 75         xing = [‘赵‘, ‘钱‘, ‘孙‘, ‘李‘, ‘周‘, ‘吴‘, ‘郑‘, ‘王‘, ‘冯‘, ‘陈‘, ‘褚‘, ‘卫‘, ‘蒋‘, ‘沈‘, ‘韩‘, ‘杨‘, ‘朱‘, ‘秦‘, ‘尤‘, ‘许‘,
 76                 ‘何‘, ‘吕‘, ‘施‘, ‘张‘, ‘孔‘, ‘曹‘, ‘严‘, ‘华‘, ‘金‘, ‘魏‘, ‘陶‘, ‘姜‘, ‘戚‘, ‘谢‘, ‘邹‘, ‘喻‘, ‘柏‘, ‘水‘, ‘窦‘, ‘章‘,
 77                 ‘云‘, ‘苏‘, ‘潘‘, ‘葛‘, ‘奚‘, ‘范‘, ‘彭‘, ‘郎‘, ‘鲁‘, ‘韦‘, ‘昌‘, ‘马‘, ‘苗‘, ‘凤‘, ‘花‘, ‘方‘, ‘俞‘, ‘任‘, ‘袁‘, ‘柳‘,
 78                 ‘酆‘, ‘鲍‘, ‘史‘, ‘唐‘, ‘费‘, ‘廉‘, ‘岑‘, ‘薛‘, ‘雷‘, ‘贺‘, ‘倪‘, ‘汤‘, ‘滕‘, ‘殷‘, ‘罗‘, ‘毕‘, ‘郝‘, ‘邬‘, ‘安‘, ‘常‘,
 79                 ‘乐‘, ‘于‘, ‘时‘, ‘傅‘, ‘皮‘, ‘卞‘, ‘齐‘, ‘康‘, ‘伍‘, ‘余‘, ‘元‘, ‘卜‘, ‘顾‘, ‘孟‘, ‘平‘, ‘黄‘, ‘和‘, ‘穆‘, ‘萧‘, ‘尹‘,
 80                 ‘姚‘, ‘邵‘, ‘堪‘, ‘汪‘, ‘祁‘, ‘毛‘, ‘禹‘, ‘狄‘, ‘米‘, ‘贝‘, ‘明‘, ‘臧‘, ‘计‘, ‘伏‘, ‘成‘, ‘戴‘, ‘谈‘, ‘宋‘, ‘茅‘, ‘庞‘,
 81                 ‘熊‘, ‘纪‘, ‘舒‘, ‘屈‘, ‘项‘, ‘祝‘, ‘董‘, ‘梁‘]
 82
 83         ming = [‘的‘, ‘一‘, ‘是‘, ‘了‘, ‘我‘, ‘不‘, ‘人‘, ‘在‘, ‘他‘, ‘有‘, ‘这‘, ‘个‘, ‘上‘, ‘们‘, ‘来‘, ‘到‘, ‘时‘, ‘大‘, ‘地‘,
 84                 ‘为‘, ‘子‘, ‘中‘, ‘你‘, ‘说‘, ‘生‘, ‘国‘, ‘年‘, ‘着‘, ‘就‘, ‘那‘, ‘和‘, ‘要‘, ‘她‘, ‘出‘, ‘也‘, ‘得‘, ‘里‘, ‘后‘, ‘自‘,
 85                 ‘以‘, ‘会‘, ‘家‘, ‘可‘, ‘下‘, ‘而‘, ‘过‘, ‘天‘, ‘去‘, ‘能‘, ‘对‘, ‘小‘, ‘多‘, ‘然‘, ‘于‘, ‘心‘, ‘学‘, ‘么‘, ‘之‘, ‘都‘,
 86                 ‘好‘, ‘看‘, ‘起‘, ‘发‘, ‘当‘, ‘没‘, ‘成‘, ‘只‘, ‘如‘, ‘事‘, ‘把‘, ‘还‘, ‘用‘, ‘第‘, ‘样‘, ‘道‘, ‘想‘, ‘作‘, ‘种‘, ‘开‘,
 87                 ‘美‘, ‘总‘, ‘从‘, ‘无‘, ‘情‘, ‘己‘, ‘面‘, ‘最‘, ‘女‘, ‘但‘, ‘现‘, ‘前‘, ‘些‘, ‘所‘, ‘同‘, ‘日‘, ‘手‘, ‘又‘, ‘行‘, ‘意‘,
 88                 ‘动‘, ‘方‘, ‘期‘, ‘它‘, ‘头‘, ‘经‘, ‘长‘, ‘儿‘, ‘回‘, ‘位‘, ‘分‘, ‘爱‘, ‘老‘, ‘因‘, ‘很‘, ‘给‘, ‘名‘, ‘法‘, ‘间‘, ‘斯‘,
 89                 ‘知‘, ‘世‘, ‘什‘, ‘两‘, ‘次‘, ‘使‘, ‘身‘, ‘者‘, ‘被‘, ‘高‘, ‘已‘, ‘亲‘, ‘其‘, ‘进‘, ‘此‘, ‘话‘, ‘常‘, ‘与‘, ‘活‘, ‘正‘,
 90                 ‘感‘, ‘见‘, ‘明‘, ‘问‘, ‘力‘, ‘理‘, ‘尔‘, ‘点‘, ‘文‘, ‘几‘, ‘定‘, ‘本‘, ‘公‘, ‘特‘, ‘做‘, ‘外‘, ‘孩‘, ‘相‘, ‘西‘, ‘果‘,
 91                 ‘走‘, ‘将‘, ‘月‘, ‘十‘, ‘实‘, ‘向‘, ‘声‘, ‘车‘, ‘全‘, ‘信‘, ‘重‘, ‘三‘, ‘机‘, ‘工‘, ‘物‘, ‘气‘, ‘每‘, ‘并‘, ‘别‘, ‘真‘,
 92                 ‘打‘, ‘太‘, ‘新‘, ‘比‘, ‘才‘, ‘便‘, ‘夫‘, ‘再‘, ‘书‘, ‘部‘, ‘水‘, ‘像‘, ‘眼‘, ‘等‘, ‘体‘, ‘却‘, ‘加‘, ‘电‘, ‘主‘, ‘界‘,
 93                 ‘门‘, ‘利‘, ‘海‘, ‘受‘, ‘听‘, ‘表‘, ‘德‘, ‘少‘, ‘克‘, ‘代‘, ‘员‘, ‘许‘, ‘稜‘, ‘先‘, ‘口‘, ‘由‘, ‘死‘, ‘安‘, ‘写‘, ‘性‘,
 94                 ‘马‘, ‘光‘, ‘白‘, ‘或‘, ‘住‘, ‘难‘, ‘望‘, ‘教‘, ‘命‘, ‘花‘, ‘结‘, ‘乐‘, ‘色‘, ‘更‘, ‘拉‘, ‘东‘, ‘神‘, ‘记‘, ‘处‘, ‘让‘,
 95                 ‘母‘, ‘父‘, ‘应‘, ‘直‘, ‘字‘, ‘场‘, ‘平‘, ‘报‘, ‘友‘, ‘关‘, ‘放‘, ‘至‘, ‘张‘, ‘认‘, ‘接‘, ‘告‘, ‘入‘, ‘笑‘, ‘内‘, ‘英‘,
 96                 ‘军‘, ‘候‘, ‘民‘, ‘岁‘, ‘往‘, ‘何‘, ‘度‘, ‘山‘, ‘觉‘, ‘路‘, ‘带‘, ‘万‘, ‘男‘, ‘边‘, ‘风‘, ‘解‘, ‘叫‘, ‘任‘, ‘金‘, ‘快‘,
 97                 ‘原‘, ‘吃‘, ‘妈‘, ‘变‘, ‘通‘, ‘师‘, ‘立‘, ‘象‘, ‘数‘, ‘四‘, ‘失‘, ‘满‘, ‘战‘, ‘远‘, ‘格‘, ‘士‘, ‘音‘, ‘轻‘, ‘目‘, ‘条‘,
 98                 ‘呢‘, ‘病‘, ‘始‘, ‘达‘, ‘深‘, ‘完‘, ‘今‘, ‘提‘, ‘求‘, ‘清‘, ‘王‘, ‘化‘, ‘空‘, ‘业‘, ‘思‘, ‘切‘, ‘怎‘, ‘非‘, ‘找‘, ‘片‘,
 99                 ‘罗‘, ‘钱‘, ‘紶‘, ‘吗‘, ‘语‘, ‘元‘, ‘喜‘, ‘曾‘, ‘离‘, ‘飞‘, ‘科‘, ‘言‘, ‘干‘, ‘流‘, ‘欢‘, ‘约‘, ‘各‘, ‘即‘, ‘指‘, ‘合‘,
100                 ‘反‘, ‘题‘, ‘必‘, ‘该‘, ‘论‘, ‘交‘, ‘终‘, ‘林‘, ‘请‘, ‘医‘, ‘晚‘, ‘制‘, ‘球‘, ‘决‘, ‘窢‘, ‘传‘, ‘画‘, ‘保‘, ‘读‘, ‘运‘,
101                 ‘及‘, ‘则‘, ‘房‘, ‘早‘, ‘院‘, ‘量‘, ‘苦‘, ‘火‘, ‘布‘, ‘品‘, ‘近‘, ‘坐‘, ‘产‘, ‘答‘, ‘星‘, ‘精‘, ‘视‘, ‘五‘, ‘连‘, ‘司‘,
102                 ‘巴‘, ‘奇‘, ‘管‘, ‘类‘, ‘未‘, ‘朋‘, ‘且‘, ‘婚‘, ‘台‘, ‘夜‘, ‘青‘, ‘北‘, ‘队‘, ‘久‘, ‘乎‘, ‘越‘, ‘观‘, ‘落‘, ‘尽‘, ‘形‘,
103                 ‘影‘, ‘红‘, ‘爸‘, ‘百‘, ‘令‘, ‘周‘, ‘吧‘, ‘识‘, ‘步‘, ‘希‘, ‘亚‘, ‘术‘, ‘留‘, ‘市‘, ‘半‘, ‘热‘, ‘送‘, ‘兴‘, ‘造‘, ‘谈‘,
104                 ‘容‘, ‘极‘, ‘随‘, ‘演‘, ‘收‘, ‘首‘, ‘根‘, ‘讲‘, ‘整‘, ‘式‘, ‘取‘, ‘照‘, ‘办‘, ‘强‘, ‘石‘, ‘古‘, ‘华‘, ‘諣‘, ‘拿‘, ‘计‘,
105                 ‘您‘, ‘装‘, ‘似‘, ‘足‘, ‘双‘, ‘妻‘, ‘尼‘, ‘转‘, ‘诉‘, ‘米‘, ‘称‘, ‘丽‘, ‘客‘, ‘南‘, ‘领‘, ‘节‘, ‘衣‘, ‘站‘, ‘黑‘, ‘刻‘,
106                 ‘统‘, ‘断‘, ‘福‘, ‘城‘, ‘故‘, ‘历‘, ‘惊‘, ‘脸‘, ‘选‘, ‘包‘, ‘紧‘, ‘争‘, ‘另‘, ‘建‘, ‘维‘, ‘绝‘, ‘树‘, ‘系‘, ‘伤‘, ‘示‘,
107                 ‘愿‘, ‘持‘, ‘千‘, ‘史‘, ‘谁‘, ‘准‘, ‘联‘, ‘妇‘, ‘纪‘, ‘基‘, ‘买‘, ‘志‘, ‘静‘, ‘阿‘, ‘诗‘, ‘独‘, ‘复‘, ‘痛‘, ‘消‘, ‘社‘,
108                 ‘算‘, ‘义‘, ‘竟‘, ‘确‘, ‘酒‘, ‘需‘, ‘单‘, ‘治‘, ‘卡‘, ‘幸‘, ‘兰‘, ‘念‘, ‘举‘, ‘仅‘, ‘钟‘, ‘怕‘, ‘共‘, ‘毛‘, ‘句‘, ‘息‘,
109                 ‘功‘, ‘官‘, ‘待‘, ‘究‘, ‘跟‘, ‘穿‘, ‘室‘, ‘易‘, ‘游‘, ‘程‘, ‘号‘, ‘居‘, ‘考‘, ‘突‘, ‘皮‘, ‘哪‘, ‘费‘, ‘倒‘, ‘价‘, ‘图‘,
110                 ‘具‘, ‘刚‘, ‘脑‘, ‘永‘, ‘歌‘, ‘响‘, ‘商‘, ‘礼‘, ‘细‘, ‘专‘, ‘黄‘, ‘块‘, ‘脚‘, ‘味‘, ‘灵‘, ‘改‘, ‘据‘, ‘般‘, ‘破‘, ‘引‘,
111                 ‘食‘, ‘仍‘, ‘存‘, ‘众‘, ‘注‘, ‘笔‘, ‘甚‘, ‘某‘, ‘沉‘, ‘血‘, ‘备‘, ‘习‘, ‘校‘, ‘默‘, ‘务‘, ‘土‘, ‘微‘, ‘娘‘, ‘须‘, ‘试‘,
112                 ‘怀‘, ‘料‘, ‘调‘, ‘广‘, ‘蜖‘, ‘苏‘, ‘显‘, ‘赛‘, ‘查‘, ‘密‘, ‘议‘, ‘底‘, ‘列‘, ‘富‘, ‘梦‘, ‘错‘, ‘座‘, ‘参‘, ‘八‘, ‘除‘,
113                 ‘跑‘, ‘亮‘, ‘假‘, ‘印‘, ‘设‘, ‘线‘, ‘温‘, ‘虽‘, ‘掉‘, ‘京‘, ‘初‘, ‘养‘, ‘香‘, ‘停‘, ‘际‘, ‘致‘, ‘阳‘, ‘纸‘, ‘李‘, ‘纳‘,
114                 ‘验‘, ‘助‘, ‘激‘, ‘够‘, ‘严‘, ‘证‘, ‘帝‘, ‘饭‘, ‘忘‘, ‘趣‘, ‘支‘, ‘春‘, ‘集‘, ‘丈‘, ‘木‘, ‘研‘, ‘班‘, ‘普‘, ‘导‘, ‘顿‘,
115                 ‘睡‘, ‘展‘, ‘跳‘, ‘获‘, ‘艺‘, ‘六‘, ‘波‘, ‘察‘, ‘群‘, ‘皇‘, ‘段‘, ‘急‘, ‘庭‘, ‘创‘, ‘区‘, ‘奥‘, ‘器‘, ‘谢‘, ‘弟‘, ‘店‘,
116                 ‘否‘, ‘害‘, ‘草‘, ‘排‘, ‘背‘, ‘止‘, ‘组‘, ‘州‘, ‘朝‘, ‘封‘, ‘睛‘, ‘板‘, ‘角‘, ‘况‘, ‘曲‘, ‘馆‘, ‘育‘, ‘忙‘, ‘质‘, ‘河‘,
117                 ‘续‘, ‘哥‘, ‘呼‘, ‘若‘, ‘推‘, ‘境‘, ‘遇‘, ‘雨‘, ‘标‘, ‘姐‘, ‘充‘, ‘围‘, ‘案‘, ‘伦‘, ‘护‘, ‘冷‘, ‘警‘, ‘贝‘, ‘著‘, ‘雪‘,
118                 ‘索‘, ‘剧‘, ‘啊‘, ‘船‘, ‘险‘, ‘烟‘, ‘依‘, ‘斗‘, ‘值‘, ‘帮‘, ‘汉‘, ‘慢‘, ‘佛‘, ‘肯‘, ‘闻‘, ‘唱‘, ‘沙‘, ‘局‘, ‘伯‘, ‘族‘,
119                 ‘低‘, ‘玩‘, ‘资‘, ‘屋‘, ‘击‘, ‘速‘, ‘顾‘, ‘泪‘, ‘洲‘, ‘团‘, ‘圣‘, ‘旁‘, ‘堂‘, ‘兵‘, ‘七‘, ‘露‘, ‘园‘, ‘牛‘, ‘哭‘, ‘旅‘,
120                 ‘街‘, ‘劳‘, ‘型‘, ‘烈‘, ‘姑‘, ‘陈‘, ‘莫‘, ‘鱼‘, ‘异‘, ‘抱‘, ‘宝‘, ‘权‘, ‘鲁‘, ‘简‘, ‘态‘, ‘级‘, ‘票‘, ‘怪‘, ‘寻‘, ‘杀‘,
121                 ‘律‘, ‘胜‘, ‘份‘, ‘汽‘, ‘右‘, ‘洋‘, ‘范‘, ‘床‘, ‘舞‘, ‘秘‘, ‘午‘, ‘登‘, ‘楼‘, ‘贵‘, ‘吸‘, ‘责‘, ‘例‘, ‘追‘, ‘较‘, ‘职‘,
122                 ‘属‘, ‘渐‘, ‘左‘, ‘录‘, ‘丝‘, ‘牙‘, ‘党‘, ‘继‘, ‘托‘, ‘赶‘, ‘章‘, ‘智‘, ‘冲‘, ‘叶‘, ‘胡‘, ‘吉‘, ‘卖‘, ‘坚‘, ‘喝‘, ‘肉‘,
123                 ‘遗‘, ‘救‘, ‘修‘, ‘松‘, ‘临‘, ‘藏‘, ‘担‘, ‘戏‘, ‘善‘, ‘卫‘, ‘药‘, ‘悲‘, ‘敢‘, ‘靠‘, ‘伊‘, ‘村‘, ‘戴‘, ‘词‘, ‘森‘, ‘耳‘,
124                 ‘差‘, ‘短‘, ‘祖‘, ‘云‘, ‘规‘, ‘窗‘, ‘散‘, ‘迷‘, ‘油‘, ‘旧‘, ‘适‘, ‘乡‘, ‘架‘, ‘恩‘, ‘投‘, ‘弹‘, ‘铁‘, ‘博‘, ‘雷‘, ‘府‘,
125                 ‘压‘, ‘超‘, ‘负‘, ‘勒‘, ‘杂‘, ‘醒‘, ‘洗‘, ‘采‘, ‘毫‘, ‘嘴‘, ‘毕‘, ‘九‘, ‘冰‘, ‘既‘, ‘状‘, ‘乱‘, ‘景‘, ‘席‘, ‘珍‘, ‘童‘,
126                 ‘顶‘, ‘派‘, ‘素‘, ‘脱‘, ‘农‘, ‘疑‘, ‘练‘, ‘野‘, ‘按‘, ‘犯‘, ‘拍‘, ‘征‘, ‘坏‘, ‘骨‘, ‘余‘, ‘承‘, ‘置‘, ‘臓‘, ‘彩‘, ‘灯‘,
127                 ‘巨‘, ‘琴‘, ‘免‘, ‘环‘, ‘姆‘, ‘暗‘, ‘换‘, ‘技‘, ‘翻‘, ‘束‘, ‘增‘, ‘忍‘, ‘餐‘, ‘洛‘, ‘塞‘, ‘缺‘, ‘忆‘, ‘判‘, ‘欧‘, ‘层‘,
128                 ‘付‘, ‘阵‘, ‘玛‘, ‘批‘, ‘岛‘, ‘项‘, ‘狗‘, ‘休‘, ‘懂‘, ‘武‘, ‘革‘, ‘良‘, ‘恶‘, ‘恋‘, ‘委‘, ‘拥‘, ‘娜‘, ‘妙‘, ‘探‘, ‘呀‘,
129                 ‘营‘, ‘退‘, ‘摇‘, ‘弄‘, ‘桌‘, ‘熟‘, ‘诺‘, ‘宣‘, ‘银‘, ‘势‘, ‘奖‘, ‘宫‘, ‘忽‘, ‘套‘, ‘康‘, ‘供‘, ‘优‘, ‘课‘, ‘鸟‘, ‘喊‘,
130                 ‘降‘, ‘夏‘, ‘困‘, ‘刘‘, ‘罪‘, ‘亡‘, ‘鞋‘, ‘健‘, ‘模‘, ‘败‘, ‘伴‘, ‘守‘, ‘挥‘, ‘鲜‘, ‘财‘, ‘孤‘, ‘枪‘, ‘禁‘, ‘恐‘, ‘伙‘,
131                 ‘杰‘, ‘迹‘, ‘妹‘, ‘藸‘, ‘遍‘, ‘盖‘, ‘副‘, ‘坦‘, ‘牌‘, ‘江‘, ‘顺‘, ‘秋‘, ‘萨‘, ‘菜‘, ‘划‘, ‘授‘, ‘归‘, ‘浪‘, ‘听‘, ‘凡‘,
132                 ‘预‘, ‘奶‘, ‘雄‘, ‘升‘, ‘碃‘, ‘编‘, ‘典‘, ‘袋‘, ‘莱‘, ‘含‘, ‘盛‘, ‘济‘, ‘蒙‘, ‘棋‘, ‘端‘, ‘腿‘, ‘招‘, ‘释‘, ‘介‘, ‘烧‘, ‘误‘,
133                 ‘乾‘, ‘坤‘]
134
135         for i in range(1):
136             x = random.randint(0, len(xing))
137             m1 = random.randint(0, len(ming))
138             m2 = random.randint(0, len(ming))
139             n = (self.sex + xing[x] + ming[m1] + ming[m2])
140         return n
141
142     def create_bankAccount(self):
143         # 工行卡号开头
144         # prefix = "622202"
145         prefix = "621483"  # 招行卡
146         for i in range(10):
147             prefix = prefix + str(random.randint(0, 9))
148         # print(prefix)
149         return prefix
150
151
152 if __name__ == ‘__main__‘:
153     shul = 0
154
155     while shul < 10:
156         shul = shul + 1
157         a = fourEl(‘女‘)
158         b = a.create_name()
159         c = a.create_phone()
160         d = a.create_idcard()
161         e = a.create_bankAccount()
162
163         dateTest = ‘{},{},{},{}\n‘.format(b,c,d,e)
164         print(dateTest)
165
166         # file = open(‘/Users/zhaodi/PycharmProjects/python3/学习/自动化测试脚本/txt文档/date‘,‘a‘,encoding=‘utf-8‘)
167         file = open(‘/Users/zhaodi/PycharmProjects/python3/学习/自动化测试脚本/txt文档/Test.csv‘,‘a‘,encoding=‘utf-8‘)
168
169         file.write(dateTest)
170
171     file.close()
172     print(‘写入完成‘)

原文地址:https://www.cnblogs.com/xuelei-0728/p/11386225.html

时间: 2024-10-09 06:18:07

随机生成四要素的相关文章

java 随机生成四位数验证码

public static void main(String[] args) { // TODO 自动生成的方法存根 Random r=new Random(); String str="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//列出所有的字母数字 for(int i=0;i<4;i++)//循环4次,输出四个数 { int a=r.nextInt(62);//从0-61中随机一个数,作为字

[GO]随机生成四们数字

package main import ( "math/rand" "time" "fmt" ) func InitData(p *int) { rand.Seed(time.Now().UnixNano()) var num int //这里为什么不写成自动推导类型呢?因为如果写成自动推导类型,那就肯定需要写在for的循环里面,那样在for循环外面就无法给*p传值(因为作用域的关系) for { num = rand.Intn(10000) i

个人项目——四则运算题目的随机生成

任务:实现一个自动生成小学四则运算题目的命令行程序. 一.时间预估及实际花费时间 PSP2.1 Personal Software Process Stages Time Planning 计划 · Estimate · 估计这个任务需要多少时间 15h Development 开发 · Analysis · 需求分析 (包括学习新技术) 2h · Design Spec · 生成设计文档 0.5h · Design Review · 设计复审 (和同事审核设计文档) 0.5h · Coding

python内置的一个好玩的函数-zip,并且巧妙的实现按概率随机生成有限个数的字符串。

python有一个比较有意思的内置函数-----zip,可以把传入的两组list进行一个组合变形,再输出子元素为tuple的list,不过变形的方式比较抽象. 举个例子: A=[1,2,3,4,5,6] B=['a','b','c','d'] v1=zip(A,B) v1的结果为: [(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd')] 比较直观的理解就是,A和B是两道拉链上的扣子,生成的list的子tuple,每一组tuple就是一对扣好了的扣子,并且从每组list的

Java 随机生成中文姓名,手机号,邮编,住址

package lovo; import java.util.HashMap; import java.util.Map; /** * 随机生成中文姓名,性别,Email,手机号,住址 * @author Quentin */ public class SuperRandom { public static String base = "abcdefghijklmnopqrstuvwxyz0123456789"; private static String firstName=&quo

咸蛋系列一●《模板模式构建随机对象生成》3 自定义扩展,随机生成不重复汉字

目前网上随机生成汉字的源码很多,无外乎生成四个数字,前两个构成区码,后两个构成位,然后使用区位码对应的16进制编码转换成汉字(可参考http://www.cnblogs.com/navicy/archive/2005/05/08/150756.html). 也就是说,没生成一个汉字,需要生成4个随机数,其实,仔细想想大可不如此麻烦. 研究区位码表(http://www.mytju.com/classCode/tools/QuWeiMa_FullList.asp),我们可以发现: 1. 16进制编

软件工程课堂练习-随机生成30道四则运算练习题

习题要求:随机生成30道四则运算题 以下是程序代码: 1 #include "stdafx.h" 2 #include "stdio.h" 3 #include "time.h" 4 #include "stdlib.h" //随机器函数头文件 5 6 void print() 7 { 8 srand((int)time(0)); 9 for(int i=0;i<=29;i++) 10 { 11 int x; 12 in

随机生成验证码信息

package com.dyy.cache; import java.util.HashMap;      import java.util.Map;            /**      * 随机生成中文姓名,性别,Email,手机号,住址      */      public class RandomValue {          public static String base = "abcdefghijklmnopqrstuvwxyz0123456789";      

随机生成30道四则运算程序分析

题目要求:随机生成30到四则运算题,其中不能超过2位运算,包含真分数. 问题细化: 1.循环30次 2.四则运算方式的表示,+,-,*,/ 3.真分数的产生 4.随机产生真分数之间或者整数之间以及真分数和整数之间的运算 细化分析: 1.循环30次 2.在循环中随机产生一个1-4的随机数,表示整数运算,真分数和整数之间的运算,还是真分数之间的运算 3.在确定后,在随机产生一个1-4的随机数表示使用哪种规则,+,-,*,/ 4.真分数表示使用两个随机数,要求分子比分母小,然后用“分子/分母”表示 以