简单的翻译软件是可以读取英语、日语、韩语等各种语言的翻译服务的可自我翻译的小工具。 python写的是,摆弄界面,输入英语单词,回到车上,如果词典里有该单词,就输出相应的中文意思,提示不存在就不存在。
软件功能:
1、可以翻译菜单、编辑方框等控件;
2、支持中文版
3、软件完全免费无毒!
代码说明:
importurllib.request
importurllib.parse
importjson
导入键
导入键
root=tkinter.Tk (
root.title (简单翻译v2.0 ) )。
root.geometry(325x300 ) )。
width=325
height=325
screen width=root.winfo _ screen width (
screen height=root.winfo _ screen height ()
alignstr='%dx%d%d%d'%(width,height,(screenwidth-width )/2,
(screenheight-height )/2 ) )。
root.geometry(alignstr ) )。
defhit_me(:
content=T1.get('0.0 ',' end ' )。
temp_content=content.replace ('。' 、'.'、
content.count ()。 '。 ) )把句号变成点
请从Request URL:复制。 已删除_o
URL=' http://fanyi.Youdao.com/translate? smart result=dictsmartresult=rule '
# data是表单数据,用于复制表单数据的内容
data={}
data['i']=temp_content
data['from']='AUTO '
data['to']='AUTO '
data['smartresult']='dict '
data['client']='fanyideskweb '
data['salt']='15803439446390 '
data [ ' sign ' ]=' 8e 349204 c5d 1140741 FFE 43284595085 '
data['ts']='1580343944639 '
data [ ' bv ' ]=' bbb3ed 55971873051 bc2ff 740579 bb49 '
data['doctype']='json '
data['version']='2.1 '
data['keyfrom']='fanyi.web '
data [ ' action ' ]=' fy _ by _ click buttion '
使用urllib.parse.urlencode ()函数将字符串转换为所需的格式
将Unicode文件格式转换为uf-8编码格式
data=urllib.parse.urlencode (data ).encode (utf-8 ) ) ) ) ) ) )。
response=urllib.request.urlopen (URL,data ) )。
#解码时也用uf-8解码
html=response.read ().decode ) (utf-8 ) )。
target=json.loads(html )
T2.delete('0.0 ',' end ' )。
T2 _ text=(target [ ' translate result ' ] [0] [0] [ ' TGT ' ] )
T2.insert(1.0,t2_text ) )。
#步骤5、在窗口界面中设置Button键
#在图形界面中设置输入框控件entry并放置控件
T1=Tkinter.text(root,show=None,font=('Arial ',14 ) )
T2=Tkinter.text(root,show=None,font=('Arial ',14 ) )
L1=Tkinter.Label(root,text=)调用有道词典在线翻译. by:mmdlt,
font=(Arial )、12 )、#font字体
width=20,height=2)
#T1.text(root,height=3,wrap=WORD ) ) ) ) ) ) )。
B1=Tkinter.Button(root,text='翻译一下',font=) ' Arial ',12 )、
width=10,height=1,command=hit_me )
t1.place(x=10,y=10,width=300,height=100 ) ) ) ) ) ) ) )。
B1.place(x=10,y=120 ) ) ) ) ) ) ) ) B1.place(x=10,y=120 ) ) ) ) ) ) ) ) ) B1.B1.place )。
T2.place(x=10,y=165,width=300,height=100 ) ) ) ) ) ) ) )。
L1.place(x=10,y=290,width=300,height=20 ) ) ) ) ) ) ) ) ) ) ) ) )。
root.mainloop (