Difference between open and codecs.open in Python

前端 未结 8 503
一整个雨季
一整个雨季 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 10:13

    When you're working with text files and want transparent encoding and decoding into Unicode objects.

提交回复
热议问题