10 May

Chinese character coding problem in pyqt4

I want to save a file with a Chinese name in pyqt.

It reports: IOError: [Errno 22] invalid mode ('w') or filename: PyQt4.QtCore.QString(u'D:/Users/zhout_000/Desktop/\u672a\u547d\u540d.dxf')

Reason: the type of the filename read from the file dialog is infact “QString”, not”string”

Solve: convert QString to unicode: fileName=unicode(QtCore.QString(fileName))

Leave a Reply