How to escape HTML from an entry in Pyqt?

Asked

Viewed 49 times

0

Both Pyqt4 and Pyqt5 can interpret HTML entities. I have a place where the text is displayed in HTML format. However at the time 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 in a QLineEdit?

1 answer

0

I ended up solving the situation using the module html python3.

import html

text = html.escape(self.textChat.text())

Browser other questions tagged

You are not signed in. Login or sign up in order to post.