随笔分类 - python
摘要:1.利用Beautiful Soup去抓取p标签下class=jstest的内容 参考:http://www.showerlee.com/archives/2109 利用Beautiful Soup+Pandas+Pyqt5+Selenum进行python爬虫
阅读全文
摘要:1.shell 2.python 3.date 用法 4.$$ 代表当前进程号
阅读全文
摘要:1.使用方法 2.判断是否成功 参考:https://zhuanlan.zhihu.com/p/34191320
阅读全文
摘要:>>> xrange(5)xrange(5)>>> list(xrange(5))[0, 1, 2, 3, 4]>>> xrange(1,5)xrange(1, 5)>>> list(xrange(1,5))[1, 2, 3, 4]>>> xrange(0,6,2)xrange(0, 6, 2)>>
阅读全文
摘要:1. [debug] enter: [FrameInfo(frame=<frame object at 0x000000000096D448>, filename='E:/pythontest/sort.py', lineno=6, function='debug', code_context=['
阅读全文
摘要:通过docker run -d 方式启动容器报“Unlinking stale socket /tmp/supervisor.sock”错误,而通过docker run -it 启动后手动执行 /usr/bin/supervisord -c /etc/supervisor.conf则没问题解决:将D
阅读全文
摘要:1.http://www.goubanjia.com/ 在上面获取 使用http协议的公网IP和端口 参考:https://blog.csdn.net/qq_23934063/article/details/79063937 2. 关键代码如下: #python3# coding: utf-8fro
阅读全文
摘要:1.<class 'bs4.element.ResultSet'> 这里是字典外套了一个列表 textPid = pid[0] 2.<class 'bs4.element.Tag'> print(textPid.get_text())
阅读全文
摘要:1.分析: 如果用 urllib.request.urlopen 方式打开一个URL,服务器端只会收到一个单纯的对于该页面访问的请求,但是服务器并不知道发送这个请求使用的浏览器,操作系统,硬件平台等信息,而缺失这些信息的请求往往都是非正常的访问,例如爬虫. 有些网站验证请求信息中的UserAgent
阅读全文
摘要:2.如果是字符集出现错误,建议多选择几种字符集测试一下: 选择的经验是: 如果是爬取到的网页文件,可以查看网页文件的meta标签下的charset属性值。例如: <meta charset="UTF-8">1也可以使用notepad++打开,查看下右下角的部位,会指示该文件是那种编码。
阅读全文
摘要:#python3import refrom urllib import requestimport os class PosterSpider(object): def __init__(self, path='./'): self.path = path #the entry of this pr
阅读全文
摘要:python -m SimpleHTTPServer 447 C:\Users\linux>python -m http.server 4444 windows10
阅读全文
摘要:2、用python实现统计一篇英文文章内每个单词的出现频率,并返回出现频率最高的前10个单词及其出现次数,并解答以下问题?(标点符号可忽略) (1) 创建文件对象f后,解释f的readlines和xreadlines方法的区别? (2) 追加需求:引号内元素需要算作一个单词,如何实现? cat /r
阅读全文
摘要:#!/usr/bin/python#5!+4!+3!+2!+1! #give 3 return 3*2*1def jiechen(n): N = map(lambda x:x+1,range(n)) f = reduce(lambda x,y:x*y,N) return f #give 5 retu
阅读全文
摘要:#python3 #product new data into the queue #comsume data from the queue from queue import Queue import time , threading class product_data(threading.Th
阅读全文
摘要:join() 在调用结束前,主线程不会结束 不加的话,主线程会在子线程结束前继续执行(并行);加了join(),主线程会等待子线程结束后在继续执行下去(串行) #python3 #main print number ,stop after son thread stop #son thread pr
阅读全文
摘要:所谓工厂函数就是指这些内建函数都是类对象(实际上是类), 当你调用它们时,实际上是创建了一个类实例。 type():查看类型
阅读全文
摘要:异常信息的获取对于程序的调试非常重要,可以有助于快速定位有错误程序语句的位置。 这里获取异常(Exception)信息采用try...except...程序结构。如下所示: Python中获取异常(Exception)信息 - klchang - 博客园https://www.cnblogs.com
阅读全文
摘要:在执行 pip install mysql-python时报错: _mysql.c:29:20: error: Python.h: No such file or directory 解决方法:yum install python-devel #yum install mysql-devel.x86
阅读全文