I would like to use "utf-8" string constant because it is always confusing for me to choose between "UTF-8", "UTF8", "utf8", "utf-8", "utf-8", "utf_8"
All code samples in python documentation have syntax like:
with io.open("/tmp/a.txt", "w", encode="utf-8") as file_cursor:
file_cursor.write(text)
Can somebody tell me why is like this, maybe some best practice, zends ... ?
I would like to use code suggestion in IDE to achieve something like:
with io.open("/tmp/a.txt", "w", encode=ENCODINGS.UTF8) as file_cursor:
file_cursor.write(text)
Is there any standard constant out of the box in python core?
You could use:
import encodings
encodings.utf_8.getregentry().name
which gives 'utf-8'
.
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