[PyQt] Troubles in return html text from QtextEdit

Phil Thompson phil at riverbankcomputing.com
Fri Oct 10 12:19:30 BST 2008


On Fri, 10 Oct 2008 22:13:20 +1100, "Min Li" <inuyashalee at gmail.com> wrote:
> Hi, everyone.
> 
> I have some problem in store html text in a variable. This html text is
> displayed in the QtextEdit.
> 
> I try to use variable = str( QtextEdit.toHtml() ) to retrieve these html
> text.
> 
> However,Python Shell shows:
> 
> Traceback (most recent call last):
> variable= str(self.toHtml())
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 533-538: ordinal not in range(128)
> 
> Is there any suggestion?

Use unicode() instead of str().

Phil


More information about the PyQt mailing list