py27环境下pyside QT的QStream Unicode解码

阅读更多
                try:
                    # Python v3.
                    text = str(text, encoding='ascii')
                except TypeError:
                    # Python v2.
                    # str对象在QT里报错
                    # UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 9: ordinal not in range(128)
                    # 需要decode
                    # .decode(encoding='utf8')
                    text = str(text).decode(encoding='utf8')

 

你可能感兴趣的:(py27环境下pyside QT的QStream Unicode解码)