2020年3月10日
摘要:
lxml中的xpat详细使用介绍: import lxml import lxml.etree html=lxml.etree.parse("index.html") print(type(html)) res=html.xpath("//li") #res是一个列表,包含所有元素 print(le
阅读全文
posted @ 2020-03-10 10:17
共感的艺术
阅读(423)
推荐(0)
摘要:
lxml中的Xpath的使用: #coding:utf-8 import lxml import lxml.etree text=""" <div> <ul> <li class="item-0"><a href="link1.html">first item</a></li> <li class=
阅读全文
posted @ 2020-03-10 10:16
共感的艺术
阅读(239)
推荐(0)
摘要:
python3中运用urllib抓取贴吧的邮箱以及QQ: import urllib import urllib.request import re from urllib import parse #抓取贴吧页面数量信息 def gettiebalistnumbers(name): #计算搜索的关
阅读全文
posted @ 2020-03-10 10:14
共感的艺术
阅读(442)
推荐(0)
2020年3月9日
摘要:
人形词云,根据图片黑白形状,绘制词云: #coding:utf-8 """ Masked wordcloud Using a mask you can generate wordclouds in arbitrary shapes. """ from os import path from PIL
阅读全文
posted @ 2020-03-09 11:24
共感的艺术
阅读(1887)
推荐(0)
摘要:
汉化的simple词云: #coding:utf-8 """ Minimal Example Generating a square wordcloud from the US constitution using default arguments. """ from os import path
阅读全文
posted @ 2020-03-09 11:22
共感的艺术
阅读(169)
推荐(0)
摘要:
对于数据的平均值处理: def checkstr(mystr): try: num=eval(mystr) return True except: return False file=r"D:\python爬虫视频\爬虫代码\处理爬虫数据排序\nasa.txt" readfile=open(file
阅读全文
posted @ 2020-03-09 11:18
共感的艺术
阅读(564)
推荐(0)
摘要:
文字替换成函数返回数字进行排序: def xueli(study): if study == "博士后": return 10 elif study == "博士": return 9 elif study == "硕士": return 8 elif study == "本科": return 7
阅读全文
posted @ 2020-03-09 11:17
共感的艺术
阅读(271)
推荐(0)
摘要:
校验 mystr=input("输入数据") try: num=eval(mystr) print(num) print("ok") except: print("失败")
阅读全文
posted @ 2020-03-09 11:16
共感的艺术
阅读(141)
推荐(0)
摘要:
转自风雪飘殇博客 自己验证实现并整理,对列表和字典排序时lambda的用法。 函数介绍 sorted() sorted函数: sorted(iterable[,key][,reverse]) 函数接收三个参数:排序的变量、排序的规则、升降序选择 lambda lambda 匿名函数一般形式 def
阅读全文
posted @ 2020-03-09 11:14
共感的艺术
阅读(1036)
推荐(0)
摘要:
python中对于抓取的数据进行排序: def checkstr(mystr): try: num=eval(mystr) return True except: return False filepath=r'D:\python爬虫视频\爬虫代码\处理爬虫数据排序\nasa.txt' readfi
阅读全文
posted @ 2020-03-09 11:09
共感的艺术
阅读(398)
推荐(0)