
python
文章平均质量分 92
python
WormholeStack
All problems in computer science can be solved by another level of indirection.
展开
-
(爬虫)numpy图片转矩阵
# coding= utf-8# 图片处理import numpy # 数值计算扩展 这种工具可用来存储和处理大型矩阵from PIL import Imageimg = Image.open("text.png")Img = img.convert('L')threshold = 200table = [] # 获取灰度转二值的映射tablefor i in range(256): if i < threshold: table.append(0)原创 2020-07-20 22:13:02 · 2789 阅读 · 0 评论 -
(爬虫)通过截取网址的元素截图 识别验证码
这里我们用到了pytesseract库,下面是安装教程:不能直接用pip安装会失败我们首先下载 tesseract-ocr 地址:https://github.com/tesseract-ocr/tesseract/wiki下载完.exe 安装并下载中文包然后在pycharm中安装模块pytesseract点击查看源码然后将源码中的:tesseract_cmd = 'tesseract'更改为:tesseract_cmd = r'C:\Program Files (x86)\Tesse原创 2020-07-11 17:31:51 · 1576 阅读 · 0 评论 -
手撸爬虫(天气预报)
代码:import randomimport timeimport urllib.requestimport urllib.responseimport pymysqlfrom lxml import etreeimport scheduledef sprider(): currenturl1 = "https://tianqi.moji.com/weather/china/jilin/baishan" # 白山 墨迹天气当前温度和描述 currenturl2 = "h原创 2020-05-20 11:14:21 · 572 阅读 · 0 评论 -
python 服务器后台运行
基本用法:进入要运行的py文件目录前nohup python -u test.py > test.log 2>&1 & //打印日志nohup xxxx >/dev/null 2>&1 & //不打印日志含义解释:nohup 不挂起的意思python test.py python运行test.py文件-u 代表程序不启用缓存,也就是把输出直接放到log中,没这个参数的话,log文件的生成会有延迟test.log 将输原创 2020-05-20 11:13:50 · 4068 阅读 · 0 评论 -
python mysql insert参数化
# 打开数据库连接 db = pymysql.connect("*****"//主机地址0.0.0.0格式, "*****"//用户名, "****"//密码, "*****"//数据库名, port=3306, charset='utf8') # 使用cursor()方法获取操作游标 cursor = db.cursor() try: cursor.execute("INSERT INTO table1 (name, age, height) values ('{0}',..原创 2020-05-20 11:13:16 · 4152 阅读 · 0 评论