Difference between open and codecs.open in Python

前端 未结 8 528
一整个雨季
一整个雨季 2020-12-04 09:53

There are two ways to open a text file in Python:

f = open(filename)

And

import codecs
f = codecs.open(filename, encoding=\         


        
8条回答
  •  感动是毒
    2020-12-04 09:57

    When you need to open a file that has a certain encoding, you would use the codecs module.

提交回复
热议问题