pandas.DataFrame使用笔记
摘要:df_empty = pd.DataFrame(columns=['A', 'B', 'C', 'D']) # 创建一个空的 DataFrame ------------------------------------------ df.shape[1]#列数 df.shape[0]#行数 len(df)#行数 if 'a' in df.values: print('ok')#是...
阅读全文
Python下载酷狗Top500
摘要:import requests, json, threading, queue, os, random, time, re import urllib.request import pandas as pd class ThreadDown(threading.Thread): def __init__(self, urlQueue, path, lock): supe...
阅读全文
xpath提取Tag下的所有text/匹配部分Tag名称
摘要:tree = etree.HTML(html) tag = tree.xpath('//~~')[0] text_tag = tag.xpath('string(.)').strip() #只有这个方法最可靠 tree = etree.HTML(html) node_list = tree.xpath('//div[contains(@id, "qiushi_tag")]') #id...
阅读全文
pycharm的使用
摘要:appearance Theme:Darcula Editor > Font 字体:Consolas size:13 行距:1.0 MonokaiColor Scheme > General Scheme:Monokai Color Scheme > Python Scheme:Monokai ht
阅读全文
Python 字符串相关函数
摘要:收集中...... s = 'mathsdfhgdfdelphi' print(s.startswith('math'))#判断开始字符 print(s.endswith('delphi'))#判断结束字符 print(s.lstrip('math'))#删掉左边字符 print(s.rstrip(
阅读全文
DataFrame创建
摘要:记录,方便查询,待续...... [{'a': 123, 'b': 234, 'c': 456}, {'a': 567, 'b': 678, 'c': 789}]
阅读全文
Html解析,方便速查
摘要:记性不好,收集,方便查询 lxml_xpath xpath('//button/span[contains(text(), "指定文本内容")]') #使用 xpath 定位包含指定文本内容的标签,例如:a = tree.xpath('//a[contains(text(), "下一页")]/@hr
阅读全文
爬虫实例01:多线程爬取糗事百科
摘要:练习:threading/queue/Lock/xpath
阅读全文
http请求常用模板
摘要:import random import requests from bs4 import BeautifulSoup def random_headers(): ua_lst = ['Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Versi...
阅读全文
python 定时任务
摘要:转自:https://www.cnblogs.com/LinTeX9527/p/6181523.html 最近学习到了 python 中两种开启定时任务的方法,和大家分享一下心得。 sched.scheduler() threading.Timer() sched 定时任务 使用sched的套路如下
阅读全文
Python常用时间函数
摘要:常用的时间函数如下 获取当前日期:time.time() 获取元组形式的时间戳:time.local(time.time()) 格式化日期的函数(基于元组的形式进行格式化): (1)time.asctime(time.local(time.time())) (2)time.strftime(form
阅读全文