尝试在Python 2.7中写入文本文件的一行,以下是代码:
然而,在output.txt中,我却得到了
# -*- coding: utf-8 -*-
...
f = open(os.path.join(os.path.dirname(__file__), 'output.txt'), 'w')
f.write('Smith’s BaseBall Cap') // Note the strangely shaped apostrophe
然而,在output.txt中,我却得到了
Smith's BaseBall Cap
而不是正确的编码。不确定如何纠正这个编码问题?在处理这种问题时有什么技巧吗?
â
。 - Josh Lee