Python 批量替换MySQL数据库内全部数据表全部字段的字符串

#encoding:utf-8

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="数据库用户名",
  password="数据库密码",
  database="数据库名"
)

mycursor = mydb.cursor()
mycursor.execute("SHOW TABLES")
tables = mycursor.fetchall()

for table in tables:
    table_name = table[0]
    #mycursor.execute(f"USE {table_name}")  # 使用指定的表所在的数据库
    mycursor.execute(f"SHOW COLUMNS FROM {table_name}")  # 获取表的所有列信息
    columns = mycursor.fetchall()
    for column in columns:
        column_name = column[0]
        sql = f"UPDATE {table_name} SET {column_name} = REPLACE({column_name}, '旧字符串', '新字符串')"
        mycursor.execute(sql)
    mydb.commit()

mycursor.close()
mydb.close()

Python 批量替换MySQL数据库内全部数据表全部字段的字符串

Linux上Java编译启动

#!/bin/bash

#读取lib文件夹的jar库
FILES=$(ls ./lib/*.jar)
JAVA_CP="."

for f in $FILES
do
	JAVA_CP="$JAVA_CP:$f"
done

if [ ! -f 类名.class ]
then
	#编译
	javac -cp $JAVA_CP 类名.java
fi

#启动
java -cp $JAVA_CP 类名

Linux上Java编译启动

Java 下载远程图片到本地

……………………
    public static void downloadImg(String imgUrl,String fileName) {
        final String DocumentName = fileName;
        final String DocumentPath = "imgs"+File.separator;
        final String DownloadURL = imgUrl;

        try {
            //自动创建文件夹
            File file = new File(DocumentPath);
            if (!file.exists() && !file.isDirectory()) {
                file.mkdirs();
            }
            //解析下载地址
            URL url = new URL(DownloadURL);
            URLConnection cnt = url.openConnection();
            InputStream inStream = cnt.getInputStream();
            FileOutputStream fos = new FileOutputStream(DocumentPath + DocumentName);
            int bytesum = 0;
            int byteread;
            byte[] buffer = new byte[1204];
            while ((byteread = inStream.read(buffer)) != -1) {
                bytesum += byteread;
                fos.write(buffer, 0, byteread);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
……………………

Java 下载远程图片到本地