如何在PyQt4中不键入ASCII字符而不出现错误?

时间:2019-01-27 10:50:43

标签: python python-2.7 utf-8 pyqt pyqt4

我想在python.PyQt4中创建Fuel计算器,我必须键入Not ASCII Characters,而当我运行代码时,我的字符将变为:

enter image description here

有什么解决办法吗?

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt4 import QtGui
from PyQt4 import *
from PyQt4.QtGui import *
import bs4 as bs
import urllib
import sys
reload(sys)
sys.setdefaultencoding('utf8')
print sys.getdefaultencoding()
class Window(QtGui.QMainWindow):
    def __init__(self):
        super(Window, self).__init__()
        self.setWindowTitle("FUEL CALCULATOR")
        self.setGeometry(100,100,400,300)
        self.cb = QComboBox(self)
        self.cb.addItem("რეგულარი")
        self.cb.addItem("ევრო რეგულარი")
        self.cb.addItem("პრემიუმი")
        self.cb.addItem("სუპერი")
        self.cb.addItem("დიზელი")
        self.cb.move(150,80)
        self.lbl_1 = QLabel("Enter Litre:>", self)
        self.lbl_1.move(50,120)
        self.button_1 = QPushButton("Calculate", self)
        self.button_1.move(150,160)
        self.text_box_1 = QLineEdit(self)
        self.text_box_1.move(150,120)
        self.button_1.clicked.connect(self.calculate)
        self.show()
    def calculate(self):
        sauce = urllib.urlopen("WEBSITE/NAME").read()
        soup = bs.BeautifulSoup(sauce, 'lxml')
        for paragraph in soup.find_all('div', style_="width: 40%;float: left;"):
            print(paragraph.text)

app = QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())

0 个答案:

没有答案