CODE:
class EchoClient(protocol.Protocol):
def connectionMade(self):
self.transport.write("Hello World!")
Error:
##raise TypeError("Data must not be unicode") builtins.TypeError: Data must not be unicode ##
How do i write the code to be utf-8?
Assuming you are using Python3, try:
"Hello World!".encode('utf-8')
If your data is in a str
variable, try:
# s = "Hello World!"
s.encode('utf-8')
It's seems like you're building a server, try using b'Hello World'
to convert to bytes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With