注意:
1 安装pyqt模块
2.python的IDLE默认编码为utf-8
3.去http://fanyi.youdao.com/openapi?path=data-mode,申请一个api key
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui,QtCore
import urllib
import json
from urllib import urlencode
class LH_QWidget(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.first=QtGui.QLineEdit(self) #添加一个文本框
#label1=QtGui.QLabel('+',self)
#self.second=QtGui.QLineEdit(self)
#label2=QtGui.QLabel('=',self)
self.third=QtGui.QLineEdit(self) #再添加一个文本框
button=QtGui.QPushButton('summit',self)

本文介绍如何利用Python和PyQt模块创建一个简单的英汉翻译工具。首先需要安装PyQt,接着要注意Python IDLE的默认编码为UTF-8。然后,你需要在有道翻译API网站上申请一个API Key来实现翻译功能。
最低0.47元/天 解锁文章
1327

被折叠的 条评论
为什么被折叠?



