System Design, Optimization, and Validation in a virtual environment
Wednesday, July 4, 2018
[Python 3] String and Unicode
If any kind of text string is to be sent across the network, it needs to be encoded. This is why the server is using the " encode('ascii') " method on the data it transmits. Likewise, when a client receives network data, that data is first received as raw unencoded bytes. If you print it out or try to process it as text, we're unlikely to get what we expect. Instead, we need to decode it first. This is why the client code is using " decode('ascii') " on the result.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment