How to escape HTML from a Pyqt entry?

0

Both Pyqt4 and Pyqt5 can interpret HTML entities. I have a place where the text is displayed in HTML format. However, at the moment of sending a text made by a certain QLineEdit , I need this text to be escaped, so that HTML tags are converted to certain entities, so that it is not interpreted.

Example:

#Quero escapar esse valor
text = self.textChat.text()

formattedText = self._buildChatText(message)

How do I escape an HTML from a text of a QLineEdit ?

    
asked by anonymous 23.03.2017 / 15:42

1 answer

0

I solved the situation using the html module of Python3.

import html

text = html.escape(self.textChat.text())
    
23.03.2017 / 17:26