随笔分类 -  Python

摘要:通过md5校验文件,我们可以判断文件内容是否改变,用python实现代码如下 import hashlib # 1.txt为空文本 with open("1.txt", "rb") as f: data = f.read() md5Old = hashlib.md5(data).hexdigest( 阅读全文
posted @ 2023-08-23 21:25 wstong 阅读(290) 评论(0) 推荐(0) 编辑
摘要:例如要访问静态文件 http://192.168.0.211:4010/picture/2023/08/19/1.png ,则需要配置static_folder ``` app = Flask(__name__, static_folder='') ``` 阅读全文
posted @ 2023-08-19 23:15 wstong 阅读(230) 评论(0) 推荐(0) 编辑
摘要:折腾了base64转png弄了很久,使用以下代码进行转换后图片一直打不开 import base64 imgData = "data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD后面省略" imgData = imgData.split(",")[1] i 阅读全文
posted @ 2023-08-19 19:03 wstong 阅读(761) 评论(0) 推荐(0) 编辑
摘要:import time from shutil import copytree from psutil import disk_partitions copyFlag = False def usbCopy(driver): try: path = r"D:\usb-" + time.strftim 阅读全文
posted @ 2023-08-03 16:38 wstong 阅读(63) 评论(0) 推荐(0) 编辑
摘要:1. 安装pyserial pip3 install pyserial 2. 使用方式 config.py import serial port = "COM1" baudrate = 2400 bytesize = serial.SEVENBITS stopbits = serial.STOPBI 阅读全文
posted @ 2023-07-16 22:23 wstong 阅读(46) 评论(0) 推荐(0) 编辑
摘要:### 1. 环境准备 安装相关的库 ``` pip3 install fitz -i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install PyMuPDF -i https://pypi.tuna.tsinghua.edu.cn/simple 阅读全文
posted @ 2023-07-16 10:52 wstong 阅读(860) 评论(0) 推荐(0) 编辑
摘要:### 1. 安装pdf2docx ``` pip3 install pdf2docx -i https://pypi.tuna.tsinghua.edu.cn/simple ``` ### 2. 简单使用 ``` from pdf2docx import parse pdf_file = 'tes 阅读全文
posted @ 2023-07-16 01:37 wstong 阅读(113) 评论(0) 推荐(0) 编辑
摘要:``` pip install sympy ``` ``` import sympy ``` ```py # 虚数单位i sympy.I # 𝑖 sympy.I ** 2 # -1 sympy.sqrt(-1) # 𝑖 # 自然对数的底e sympy.E # e sympy.log(sympy. 阅读全文
posted @ 2023-07-16 01:15 wstong 阅读(32) 评论(0) 推荐(0) 编辑
摘要:### 1. jionlp安装 ``` pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple jionlp ``` github地址 https://github.com/dongrixinyu/JioNLP ### 2. 简单使用 ``` 阅读全文
posted @ 2023-07-09 21:04 wstong 阅读(901) 评论(0) 推荐(0) 编辑
摘要:在使用pandas写excel时,报了IllegalCharacterError的错误,发现是存在非法字符造成的,使用xlsxwriter模块可以解决这个问题 ```py import xlsxwriter data.to_excel('out.xlsx', engine='xlsxwriter') 阅读全文
posted @ 2023-07-07 21:07 wstong 阅读(604) 评论(0) 推荐(0) 编辑
摘要:```py a = [1,3,5,7,9] # 查找第一个大于等于x的位置 def lower_bound(l, r, x): while l <= r: mid = (l+r) // 2 if a[mid] < x: l = mid + 1 else: r = mid - 1 return l # 阅读全文
posted @ 2023-06-30 12:53 wstong 阅读(11) 评论(0) 推荐(0) 编辑
摘要:```py import time import datetime def CalTime(date1, date2): # %Y-%m-%d %H:%M:%S为日期格式 # date1 = time.strptime(date1, '%Y-%m-%d %H:%M:%S') # date2 = ti 阅读全文
posted @ 2023-06-29 16:28 wstong 阅读(234) 评论(0) 推荐(0) 编辑
摘要:### 1.web端控制台代码 ``` const successCallback = function(data) { console.log(data); } var import_js = document.createElement('script'); import_js.setAttri 阅读全文
posted @ 2023-06-21 20:11 wstong 阅读(53) 评论(0) 推荐(0) 编辑
摘要:需要接收一个json对象,然后判断主键是否存在后执行插入操作 服务端 ``` from flask import Flask, request, jsonify from gevent import pywsgi import pymysql import config import json ap 阅读全文
posted @ 2023-06-12 19:25 wstong 阅读(874) 评论(0) 推荐(0) 编辑
摘要:最近在研究一个网站发现网站使用了des加密,觉得使用python调用js可读性比较高,所以使用了以下方法来实现该网站的内容解密 ### 1. 安装PyExecJS ``` pip3 install PyExecJs ``` ### 2. 安装node.js https://nodejs.org/en 阅读全文
posted @ 2023-06-09 12:38 wstong 阅读(1505) 评论(0) 推荐(0) 编辑
摘要:最近在看到一个之前做的sqlite数据库时发现忘了table名叫什么了,所以找了找发现可以直接用python查询,记录一下 ``` import sqlite3 conn = sqlite3.connect('test.db') cur = conn.cursor() sql = "select * 阅读全文
posted @ 2023-06-08 20:50 wstong 阅读(607) 评论(0) 推荐(0) 编辑
摘要:最近在做bytes转str时,出现报错 ```py str(test, encoding='utf-8') ``` 改成 GB2312、gbk、ISO-8859-1 就没报错 ``` str(test, encoding='GB2312') str(test, encoding='gbk') str 阅读全文
posted @ 2023-06-08 19:26 wstong 阅读(41) 评论(0) 推荐(0) 编辑
摘要:### 1. 安装相关库和下载相关文件 ``` pip3 install selenium pip3 install msedge-selenium-tools ``` 在 https://developer.microsoft.com/zh-cn/microsoft-edge/tools/webd 阅读全文
posted @ 2023-05-22 18:55 wstong 阅读(539) 评论(0) 推荐(0) 编辑
摘要:pip3 install moviepy -i https://pypi.tuna.tsinghua.edu.cn/simple from moviepy.audio.io.AudioFileClip import AudioFileClip from moviepy.editor import c 阅读全文
posted @ 2023-05-15 13:02 wstong 阅读(418) 评论(0) 推荐(0) 编辑
摘要:pip3 install PyQt5 -i https://pypi.tuna.tsinghua.edu.cn/simple pip3 install PyQt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple 安装后可以 C:\Users\X\A 阅读全文
posted @ 2023-05-10 10:02 wstong 阅读(22) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示