Hongmu Notes
Home Language Notes python

python

Python was designed in the early 1990s by Guido van Rossum of the Dutch Mathematical and Computer Science Research Society as an alternative to the ABC language. Python offers efficient high-level data structures and supports simple, effective object-oriented programming. Its syntax, dynamic typing, and the inherent nature of an interpreted language make it ideal for writing scripts and performing rapid development across a wide range of platforms...

Python organizes data shared in batches on Baidu Netdisk

Python organizes data shared in batches on Baidu Netdisk Language Notes python

import pandas as pd import re import os # ---------- Input and output path ---------- csv_path = r"C:\Users\18102\Downloads\jietu\Baidu network disk sharing.csv" output_excel = r"C:\Use…
👁 48
python batch publish articles to wordpress sub-theme

python batch publish articles to wordpress sub-theme Language Notes python

Capture packets through fidder and write a python script. It is very convenient to collect articles and then publish them to the website. But this script is only suitable for use on this site. The code is currently placed here for backup. import requests import pandas as pd import re import time import os import jso…
👁 81
Python compresses website images in batches to slim down the website!

Python compresses website images in batches to slim down the website! Language Notes python

My website is very slow to open because the images are very large. So I thought of using python to compress images. Compress png into webp format, directly reducing the weight by 88%! The compression rate is very high, but it is very clear. 1.4G png is directly compressed to 120M, and it is very high-definition. Anyone else? ! The function of the Python script: recursively traverse all files in the uploads directory. Skip less than or equal to 300KB…
👁 432
Python batch cuts the left and right sides of pictures

Python batch cuts the left and right sides of pictures Language Notes Summary of pitfalls python

python code to automatically detect the distance between both sides of the image: import cv2 import numpy as np image_path = r"C:\Users\18102\Downloads\ok\0001.png" # Please change to the actual screenshot path img = cv2.imread(image_path) if …
👁 61
Python image query to remove duplicates and detect whether the file exists

Python image query to remove duplicates and detect whether the file exists Language Notes python

Use the script for your own use, keep the backup import os import re # ---------- Configuration ---------- ok_dir = r"C:\Users\18102\Downloads\ok" output_missing = "missing.txt" # Output to the directory where the current script is located # -------…
👁 49
Python measures picture width and height, interactive measurement script

Python measures picture width and height, interactive measurement script Language Notes python

import cv2 import numpy as np image_path = r"C:\Users\18102\Downloads\bg.png" # Read the image (retain alpha channel) img = cv2.imread(image_path, cv2.IMREAD_UNCHANGED) if …
👁 61
python cooperates with winrar to specify folders and package in batches

python cooperates with winrar to specify folders and package in batches Language Notes python

I recently tinkered with it and it works pretty well. Make a backup. So that you can’t find it next time. #!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import re import subprocess import os import sys from pathlib i…
👁 53
Combine multiple Python articles into a single article.

Combine multiple Python articles into a single article. Language Notes python

A friend mentioned needing to combine multiple Markdown-format files or articles into a single document. The requirement is quite simple: merge several TXT files from a folder into one document in sequential order. The output format should be as follows: <h3>Document 1 – File Name</h3> – Document 1 Content <h3>Document 2 – File Name</h3> – Document 2 Content <h3>Document 3 – File Name...
👁 201
Python code to print a Buddha statue

Python code to print a Buddha statue Language Notes python

A fun Python print statement example! print(&_oo0oo_") print(&_oo8888888o_") print(&_oo88\". \"88_") print(&_oo(| -_- |)_") print(&_oo0\\ = /0_") print(&_oo___/ '---' \\___") print(&_oo.'..._")
👁 1011
Python converts Markdown to HTML – Code Backup

Python converts Markdown to HTML – Code Backup Language Notes python

It took a whole day to get this thing working – I ran into some issues with Markdown. Let me back up my code here to prevent any loss! I've packaged it into a standalone software package; feel free to download it from: https://www.4s5.cn/archives/1310.html🔒 Hidden content: Paid reading – import os import re import logging import markdown...
👁 167
1 2 3