0

I am studying python and I have a question about encoding.

I have a txt file that contains:

00000 UNITED STATES
01000 ALABAMA
01001 Autauga County, AL
01003 Baldwin County, AL
01005 Barbour County, AL
01007 Bibb County, AL 

and so on.

I open it with

f=open(namefile)

I have read that there is an option called encoding (the name of the encoding used to decode or encode the file). What is the main purpose of it? For example if the txt file was written in binary would it be able to translate it? In my case it would be useless.

martineau
  • 119,623
  • 25
  • 170
  • 301
MementoMori
  • 283
  • 4
  • 10
  • Possible duplicate of [Usage of unicode() and encode() functions in Python](https://stackoverflow.com/questions/10288016/usage-of-unicode-and-encode-functions-in-python) – shaik moeed Oct 22 '19 at 09:34
  • Read [this](https://stackoverflow.com/questions/11339955/string-encoding-and-decoding). – shaik moeed Oct 22 '19 at 09:38
  • Possible duplicate of [What is character encoding and why should I bother with it](https://stackoverflow.com/questions/10611455/what-is-character-encoding-and-why-should-i-bother-with-it) – snakecharmerb Oct 22 '19 at 09:48
  • Thank you i will read them @shaikmoeed – MementoMori Oct 22 '19 at 10:20

0 Answers0