
Python
雪落南城
这一场人间流浪,长随步履温柔相候
展开
-
python多线程读文件
from io import openfrom concurrent.futures import ThreadPoolExecutor,wait,ALL_COMPLETEDclass read_file(object): def __init__(self): self.file_count = [1,2] """ 读文件 """ def thread_pool(self): print('读取文件开始') executor = ThreadPo原创 2020-08-26 15:32:09 · 1432 阅读 · 0 评论 -
python项目进行包管理
今天接手了一个前辈开发的python项目,但是里边的好多包我都没有下过,一开始,我一个一个的点开py文件,然后下载报红的import。。。然后我觉得,java有maven这种神器,python应该也会有类似的吧。。经查之,python项目中会维护一个requirements.txt文件,里面是各种引入包的描述,类比pom文件1、生成该文件pip freeze >r...原创 2020-01-21 18:18:01 · 679 阅读 · 0 评论 -
Python-下载MP3
def DownloadFile(self): for i in self.map3_names: try: mp3_url = self.url_list.get(i) mp3_name = i + '.mp3' if mp3_url is None or self.save_path is Non...原创 2019-11-12 00:53:38 · 2027 阅读 · 0 评论 -
Python窗口
import tkinter as tkclass window(): def __init__(self): self.x = '' self.y = '' self.e = None window = tk.Tk() window.title("autoClick") window.geomet...原创 2019-03-29 10:56:29 · 802 阅读 · 0 评论 -
Python识别pdf表格
import pdfplumberimport pandas as pdpath = '/Users/wecash/Desktop/000001.pdf'if __name__ == '__main__': with pdfplumber.open(path) as pdf: page = pdf.pages[27] text = page.ex...原创 2019-06-19 16:35:51 · 4442 阅读 · 0 评论 -
Python之爬虫学习(八)----代理失效时使用本机IP
from urllib import requestfrom urllib import errorfrom bs4 import BeautifulSoupimport randomfrom io import openimport requestsimport timeimport osfrom concurrent.futures import ThreadPoolExec...原创 2019-06-10 17:51:31 · 62367 阅读 · 0 评论 -
Python获取路径下的文件名
importos deffile_name(file_dir): forroot,dirs,filesinos.walk(file_dir): print(root)#当前目录路径 print(dirs)#当前路径下所有子目录 print(files)#当前路径下所有非目录子文件...原创 2019-06-04 16:10:57 · 19927 阅读 · 1 评论 -
Python驱动级按键-pywin32的使用
实践证明 pyinput会被游戏屏蔽winio只适合PS/2 圆口键盘下面使用参考:https://mp.weixin.qq.com/s/WXf5JVyyFZqp-DYlGigL-gwin32api:准备:安装好pywin32,pip insatall pywin32然后使用时import win32apiimport win32con #导入这两个模块im...原创 2019-03-27 13:53:04 · 12931 阅读 · 10 评论 -
Python之爬虫学习(二)
基本格式import urllib.requestimport urllib.parseimport jsonif __name__ == "__main__": #对应上图的Request URL Request_URL = 'http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=r...原创 2019-03-13 19:34:57 · 257 阅读 · 0 评论 -
Python多线程使用
from concurrent.futures import ThreadPoolExecutor,wait,ALL_COMPLETED使用线程池executor = ThreadPoolExecutor(max_workers=4)for companyUrl in self.companylist: executor.submit(AnnualReport.getlist...原创 2019-03-18 16:20:46 · 204 阅读 · 0 评论 -
Python之爬虫学习(三)
from urllib import requestfrom bs4 import BeautifulSoupif __name__ == "__main__": url = 'http://vip.stock.finance.sina.com.cn/corp/view/vCB_AllBulletinDetail.php?stockid=000004&id=4386458'...原创 2019-03-14 14:27:38 · 176 阅读 · 0 评论 -
Python之爬虫学习(四)
from urllib import requestfrom urllib import errorfrom bs4 import BeautifulSoupimport randomimport timeclass AnnualReport(object): def __init__(self): 'http://vip.stock.finance.si...原创 2019-03-15 09:47:10 · 670 阅读 · 0 评论 -
Python之爬虫学习(六)---成品
涉及知识点Python 读取/写入txttime暂停线程池下载pdf爬虫 UA代理、IP代理from urllib import requestfrom urllib import errorfrom bs4 import BeautifulSoupimport randomfrom io import openimport requestsimport timefr...原创 2019-03-19 16:56:56 · 1919 阅读 · 0 评论 -
Python之爬虫学习(七)----问题记录
1、代理IP质量问题获取到的代理IP可能会失效,所以需要多次校验IP的质量及记录问题url重新请求获取时校验:# 获取可用IP代理def getIplist(self): print('get ip proxy start...') url = 'https://www.xicidaili.com/nn/' header = { 'User-...原创 2019-03-20 11:13:48 · 308 阅读 · 0 评论 -
Python import
import导入的是modulemodule就是 xxx.py文件当我们使用import时 需要 package_name.module_name1.定义:模块(module):用来从逻辑(实现一个功能)上组织Python代码(变量、函数、类),本质就是*.py文件。文件是物理上组织方式"module_name.py",模块是逻辑上组织方式"module_name"。包(p...原创 2019-03-21 14:11:43 · 193 阅读 · 0 评论 -
Python-鼠标自动点击
两种库都可以pip install PyUserInputpip install PyAutoGUIimport pyautoguifrom pymouse import PyMouseclass MouseClick: def __init__(self,x,y): self.x = x self.y = y def star...原创 2019-03-21 15:06:15 · 10264 阅读 · 0 评论 -
Python-读取/写入文件
使用txtname = '/Users/wecash/Desktop/report/' + str(self.count) + '.txt';with open(txtname, 'w') as f: f.write(str(texts[0]))txtname4 = '/Users/wecash/Desktop/validurl/validreports97.txt'cou...原创 2019-03-21 15:54:25 · 443 阅读 · 0 评论 -
Python之爬虫学习(五)
爬虫 UA代理 IP代理 文本写入 pdf获取示例代码from urllib import requestfrom urllib import errorfrom bs4 import BeautifulSoupfrom pdfminer.pdfinterp import PDFResourceManager, process_pdffrom pdfminer.converter...原创 2019-03-18 12:42:10 · 8134 阅读 · 0 评论 -
Python之爬虫学习(一)
1、工具PyCharm2、安装Python环境http://www.runoob.com/python/python-install.htmlhttps://www.python.org/downloads/mac-osx/3、引入三方库ok了。原创 2019-03-13 12:52:25 · 226 阅读 · 0 评论 -
Python调用驱动级按键--DD虚拟键盘
开发DNF连点功能时,常规的PyMouse PyKeyboard无效猜测原因是DNF屏蔽了模拟信号尝试使用驱动级按键作者:石头三颗链接:https://www.zhihu.com/question/42888871/answer/385506293来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。比如DD虚拟键盘虚拟鼠标这个官方例子里就有p...原创 2019-03-25 10:32:02 · 16278 阅读 · 5 评论 -
Python3编码gb2312问题
网页上的编码是gb2312但是转码时报 'gb2312' codec can't decode byte 0x89 in position 42485: illegal multibyte sequence将gb2312改为gb18030即可url = 'http://vip.stock.finance.sina.com.cn/corp/view/vCB_AllBulletin...原创 2019-03-14 14:12:57 · 5706 阅读 · 0 评论