文章分类 -  python练习题

摘要:import re 读取带匹配的数据 with open(r'lv.txt', 'r', encoding='utf8') as f: data = f.read() 利用正则匹配数据 分公司名称 title_list = re.findall('\n(.*?)\n', data) print(ti 阅读全文
posted @ 2021-11-29 09:54 弑悟 阅读(11) 评论(0) 推荐(0)
摘要:import random def v_code(n): code = '' for i in range(n): num=random.randint(0,9) alf=chr(random.randint(65,90)) add=random.choice([num,alf]) code="". 阅读全文
posted @ 2021-11-29 09:42 弑悟 阅读(7) 评论(0) 推荐(0)
摘要:def add(a, b): return a + b def test(): for r in range(4): yield r g = test() g = (add(10, i) for i in (add(10, i) for i in g)) print(list(g)) def tes 阅读全文
posted @ 2021-11-29 09:02 弑悟 阅读(10) 评论(0) 推荐(0)
摘要:""" 猜年龄的游戏 普通要求 用户可以有三次猜错的机会 如果过程中猜对了直接退出 拔高要求 三次机会用完之后提示用户是否继续尝试 如果是则再给三次机会 如果否则直接结束 数据类型转换提示 """ count = 0 while count < 3: age = input('猜一猜美女的年龄:') 阅读全文
posted @ 2021-11-04 16:33 弑悟 阅读(27) 评论(0) 推荐(0)