摘要: import re #过滤出中国,其中name不一定总为name str = '<div class ="name">中国</div>' resu = re.findall(r'<div class =".*">(.*?)</div>',str) print(resu) #过滤中文:汉字整体打印 s 阅读全文
posted @ 2019-11-12 15:28 jxba 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #字典value值排序,key值排序 from random import * dict1 = {x:randint(5,12) for x in "aijwt"} dict2 = {randint(5,12):y for y in "aibjwte"} print ('dict1:',dict1) 阅读全文
posted @ 2019-11-12 11:37 jxba 阅读(700) 评论(0) 推荐(0) 编辑
摘要: #字符串中的数字排序 b = '1534788912' print ("将b排序显示,办法(列表):") listb = list(b) #['1', '5', '3', '4', '7', '8', '8', '9', '1', '2'] for i in range(0, len(listb)- 阅读全文
posted @ 2019-11-12 10:17 jxba 阅读(3645) 评论(0) 推荐(0) 编辑
摘要: # 计算出以下字符串,每个字符出现的次数 a = "hello,world!" print('a=',a) #办法1 print ("统计a中各项的个数,办法1(字典):") dicta = {} for i in a: dicta[i] = a.count(i) print (dicta) # 办 阅读全文
posted @ 2019-11-12 09:28 jxba 阅读(16242) 评论(0) 推荐(0) 编辑