3

我在 MySQL 中寻找等效的 javascript 函数 encodeURIComponent() ( http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp ) 但找不到它。有人知道MySQL中是否存在这样的功能吗?

4

1 回答 1

0

试试这个python代码

import MySQLdb
import urllib
db = MySQLdb.connect(host=" ",    # your host, usually localhost
                     user=" ",         # your username
                     passwd=" ",  # your password
                     db=" ")      # your database name

cur = db.cursor()
cur.execute("SELECT column_name FROM table_name")
for row in cur.fetchall():
    a = {row[1][:15]:row[1][15:]}
    b = urllib.urlencode(a) 
    print(b)   
    query="Update table_name set column_name ='" + b + "' where id=" + str(row[0]) +';'
    cur.execute(query)
    db.commit()
db.close()
于 2020-02-03T07:32:37.520 回答