Jetbrains 可以呀,这个ui 相当棒
from database import Sqlite3Database
from googletrans import Translator
import csv
if __name__ == "__main__":
TRANS_EN2ZH = False
translator = Translator()
sqlite = Sqlite3Database("./drurmu.db")
sqlite.rawExec(
"CREATE TABLE IF NOT EXISTS \
zhTable(ID INT PRIMARY KEY,NAME TEXT UNIQUE NOT NULL)"
)
_, dataTable = sqlite.readData("rmu")
# transTable enlish 2 chinese
if TRANS_EN2ZH:
transTable = {}
for it in dataTable:
transTable[it[0]] = it[1]
zhTable = {}
for _it in transTable:
zhTable[_it] = translator.translate(transTable[_it], dest="zh-cn").text
for __it in zhTable:
sqlite.addData("zhTable", [(__it, zhTable[__it])])
with open("./zhTable.csv") as csvfile:
spamreader = csv.reader(csvfile)
for it in spamreader:
sqlite.updateData(
"zhTable",
[
"NAME='%s'" % (it[1]),
],
"WHERE ID='%s'" % (it[0]),
)
sqlite.write2database()