1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Python 2.7: difference between codecs.open(<f>, 'r', encoding=<enc>) and...

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 17:12.

  1. Stack

    Stack Membro Participativo

    What is the difference between code like this:

    with codecs.open(<file path>, 'r', encoding='my_enc') as f:
    json.load(f)
    string = json['key']


    and code like this:

    with open(<file path>, 'r') as f:
    json.load(f)
    string = json['key'].encode('my_enc')


    There must be differences since the first doesnt work for my application, but I dont understand why exactly. I feel some misunderstanding of how this encoding stuff works.

    I am using Python 2.7 and cannot update it since I receive this environment and I am limited by this.

    Continue reading...

Compartilhe esta Página