Compare commits
1 Commits
main
...
release/1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
216cb4be52 |
BIN
__pycache__/BaiduTrans.cpython-39.pyc
Normal file
BIN
__pycache__/BaiduTrans.cpython-39.pyc
Normal file
Binary file not shown.
BIN
__pycache__/tclient.cpython-39.pyc
Normal file
BIN
__pycache__/tclient.cpython-39.pyc
Normal file
Binary file not shown.
33
trans.py
33
trans.py
@@ -6,6 +6,7 @@ import os
|
||||
import re
|
||||
import time
|
||||
from tclient import tenTrans
|
||||
from pypinyin import pinyin, lazy_pinyin, Style
|
||||
|
||||
def getinfo(oldWord):
|
||||
print('查询多语言------------------------ ')
|
||||
@@ -37,9 +38,19 @@ def transI18(oldWord:str,newWord:str,Idword:str):
|
||||
try:
|
||||
# newkey=newWord.replace(' ','-') +'-'+str(random.randint(1,10000) )
|
||||
newkey=newWord.replace(' ','_') +'_'+str(random.randint(1,10000) ) # 下划线容易复制
|
||||
# 截取70个字符
|
||||
newkey=newkey[0:71]
|
||||
newkey=newkey+'_'+str(random.randint(1,10000))
|
||||
|
||||
|
||||
except:
|
||||
newkey=oldWord+'-'+str(random.randint(1,10000))
|
||||
# lazy_pinyin('中心') ['zhong', 'xin']
|
||||
newkey='_'.join(lazy_pinyin(oldWord)) +'_'+str(random.randint(1,10000))
|
||||
# 截取70个字符
|
||||
newkey=newkey[0:71]
|
||||
newkey=newkey+'_'+str(random.randint(1,10000))
|
||||
|
||||
# newkey=oldWord+'-'+str(random.randint(1,10000))
|
||||
print('生成key: ',newkey)
|
||||
r = getinfo(oldWord)
|
||||
newlist=r.json()["data"]
|
||||
@@ -62,20 +73,26 @@ def transI18(oldWord:str,newWord:str,Idword:str):
|
||||
else:
|
||||
pass
|
||||
# print('数据库不存在------------------------ ')
|
||||
#post新增接口
|
||||
|
||||
if newWord!='None' :
|
||||
r =postData(oldWord,newWord,newkey)
|
||||
print('post----',r.json())
|
||||
if oldWord not in itemArr:
|
||||
print('数据库不存在------------------------ ')
|
||||
#post新增接口
|
||||
# r =postData(oldWord,newWord,Idword,newkey)
|
||||
if newWord != None:
|
||||
print('newWord',newWord)
|
||||
r =postData(oldWord,newWord,Idword,newkey)
|
||||
else:
|
||||
print('请检查代理是否关闭')
|
||||
|
||||
else:
|
||||
# print('没有查询结果')
|
||||
#post新增接口
|
||||
newWord!='None' :
|
||||
if newWord != None:
|
||||
print('newWord',newWord)
|
||||
r =postData(oldWord,newWord,Idword,newkey)
|
||||
else:
|
||||
print('请检查代理是否关闭')
|
||||
|
||||
|
||||
|
||||
# print('即将替换的key值------------------------ ',newkey)
|
||||
return newkey
|
||||
|
||||
|
||||
Reference in New Issue
Block a user