上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: 1. beautifulsoup 获取标签内容 https://cuiqingcai.com/1319.html 2.正则匹配优先量词与忽略优先量词 https://www.cnblogs.com/nzbbody/p/4391792.html 3. 列表倒序 4.豆瓣API使用 5.python单下 阅读全文
posted @ 2018-01-12 23:43 huahuayu 阅读(268) 评论(0) 推荐(0) 编辑
摘要: re.findall(pattern,string)会搜索所有匹配的字符,返回的是一个列表,获取首个匹配需要re.findall(pattern,string)[0]访问, 但是如果findall没匹配成功则返回空列表,这时用列表下标去访问元素时就会报IndexError: list index o 阅读全文
posted @ 2018-01-09 21:51 huahuayu 阅读(3321) 评论(0) 推荐(0) 编辑
摘要: BeautifulSoup中可以通过name和attrs去定位名称和属性,以找到特定的html代码。更值得称赞的是,attrs支持正则表达式。 如: <div class="cool"> <h1 class="abc">design</h1> </div> 搜索此行,可以这样写 abcSoup = 阅读全文
posted @ 2018-01-07 16:36 huahuayu 阅读(4423) 评论(0) 推荐(0) 编辑
摘要: 1. 获取字符串中间的一段内容 阅读全文
posted @ 2018-01-07 14:15 huahuayu 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 1. 从字典创建Dataframe 2. 从列表创建Dataframe (先把列表转化为字典,再把字典转化为DataFrame) 3. 从列表创建DataFrame,指定data和columns 4. 修改列名,从['id','name','sex']修改为['Id','Name','Sex'] 5 阅读全文
posted @ 2018-01-07 10:36 huahuayu 阅读(35074) 评论(0) 推荐(0) 编辑
摘要: 独学而无友,则孤陋而寡闻,python学习过程中希望多和学友交流,一起进步。 开源中国 j_hao104 微信公众号: Pythoner每日一报 https://my.oschina.net/jhao104/home 也在学习python的cnblog网友 aubucuo https://www.c 阅读全文
posted @ 2018-01-06 00:22 huahuayu 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Python学习过程中觉得不错的学习资源记录于此,长期更新: 用Python玩转数据 Data Processing Using Python - Coursera https://www.coursera.org/learn/hipython/home/welcome Python 爬虫学习系列教 阅读全文
posted @ 2018-01-05 22:47 huahuayu 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 以豆瓣为例,访问https://www.douban.com/contacts/list 来查看自己关注的人,要登录才能查看。 如果用requests.get()方法获取这个http,没登录只能抓取回一个登录界面,所以我们要用Python登录网站才能抓取想要的网页。 一个简便的方法就是自己在浏览器上 阅读全文
posted @ 2018-01-05 22:07 huahuayu 阅读(2998) 评论(3) 推荐(0) 编辑
摘要: 官方文档: sort(*, key=None, reverse=False) This method sorts the list in place, using only < comparisons between items. Exceptions are not suppressed - if 阅读全文
posted @ 2018-01-02 23:44 huahuayu 阅读(2569) 评论(0) 推荐(1) 编辑
摘要: pop和remove方法都可以删除list中的元素,个人更倾向于使用pop方法。 pop方法:删除过程中还能返回被删除的值 remove方法: 从左往右,删除首次出现的指定元素 删除过程不会返回被删除的值 阅读全文
posted @ 2018-01-02 23:10 huahuayu 阅读(23433) 评论(0) 推荐(2) 编辑
上一页 1 ··· 5 6 7 8 9 10 下一页