I would like to generate a UUID v4 string starting from the uuid import from the Python standard library. I know I can cast a UUID to str by doing str(uuid.uuid4()), however I am trying to understand what the bytes in that class instance mean. While trying to decode those bytes I see all sorts of errors, either the string
Tag: utf
How to escape unicode special chars in string and write it to UTF encoded file
What I aim to achieve is to: string like: convert to: and write it in this form to file (which is UTF-8 encoded). Answer Another solution, not relying on the built-in repr() but rather implementing it from scratch: Differences: Encodes only using u, never any other sequence, whereas repr() uses about a third of the alphabet (so for example the