多语言-nacos的配置分组保存
This commit is contained in:
@@ -22,7 +22,7 @@ def baidu_translate(word):
|
||||
api_data = {
|
||||
'q': word,
|
||||
'from': 'cht',
|
||||
'to': 'en',
|
||||
'to': 'ara',
|
||||
'appid': appid,
|
||||
'salt': salt,
|
||||
'sign': sign
|
||||
@@ -30,7 +30,7 @@ def baidu_translate(word):
|
||||
req_get = requests.get(api_url, api_data)
|
||||
# 结果的位置可能不同
|
||||
result_json = req_get.json()
|
||||
print(result_json)
|
||||
# print(result_json)
|
||||
result: str = ''
|
||||
if 'trans_result' in result_json:
|
||||
result = result_json['trans_result'][0]['dst']
|
||||
@@ -85,28 +85,28 @@ if __name__ == '__main__':
|
||||
# print(e)
|
||||
# continue
|
||||
for m in msgs:
|
||||
while True:
|
||||
try:
|
||||
if len(m) == 0:
|
||||
continue
|
||||
arr = m.split(', ')
|
||||
str1: str = ''
|
||||
if len(arr) > 0:
|
||||
str1 = arr[0]
|
||||
str2: str = ''
|
||||
if len(arr) > 1:
|
||||
str2 = arr[1]
|
||||
if len(str2) == 0:
|
||||
continue
|
||||
else:
|
||||
str2 = str2.split(')')[0]
|
||||
str2 = str2.replace('"', '')
|
||||
content = baidu_translate(str2)
|
||||
if len(str1) > 0 and '(' in str1:
|
||||
str1 = str1.split('(')[0]
|
||||
print('BusiStatus.', str1, '=', content)
|
||||
time.sleep(1)
|
||||
break
|
||||
except Exception as e:
|
||||
print(e)
|
||||
try:
|
||||
if len(m) == 0:
|
||||
continue
|
||||
arr = m.split(', ')
|
||||
str1: str = ''
|
||||
if len(arr) > 0:
|
||||
str1 = arr[0]
|
||||
str2: str = ''
|
||||
if len(arr) > 1:
|
||||
str2 = arr[1]
|
||||
if len(str2) == 0:
|
||||
continue
|
||||
else:
|
||||
str2 = str2.split(')')[0]
|
||||
str2 = str2.replace('"', '')
|
||||
content = str2
|
||||
# content = baidu_translate(str2)
|
||||
if len(str1) > 0 and '(' in str1:
|
||||
str1 = str1.split('(')[0]
|
||||
print('BusiStatus.', str1, '="', content, '"')
|
||||
# time.sleep(1)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
continue
|
||||
|
||||
|
Reference in New Issue
Block a user