我目前正在使用Python 2.7解析大型文本文件,其中一些最初是用Unicode或UTF-8编码的.
对于包含直接与UTF-8中的字符串交互的函数的模块,我包含# -*- coding: utf-8 -*-在文件的顶部,但对于仅使用ascii的函数,我没有打扰.
# -*- coding: utf-8 -*-
最终,这些模块导致更大的模块,并且所有解析的字符串混合在一起.包含# -*- coding: utf-8 -*-在每个文件的顶部是一种好习惯吗?
这有益处吗?
python unicode parsing ascii utf-8
ascii ×1
parsing ×1
python ×1
unicode ×1
utf-8 ×1