Python 2.7 ';wb&x27;vs';w';在Unix for Python中

Python 2.7 ';wb&x27;vs';w';在Unix for Python中,python-2.7,file,unix,Python 2.7,File,Unix,许多帖子认为在Unix环境中,wb和w之间没有区别,例如。但我的正好相反 环境是Ubuntu 16.04和Python 2.7.13。执行以下代码 from __future__ import print_function log = open("output.txt", "w") print('{:02d} {} {} {} {} {}'.format( queryID, "Q0", match[

许多帖子认为在Unix环境中,
wb
w
之间没有区别,例如。但我的正好相反

环境是Ubuntu 16.04和Python 2.7.13。执行以下代码

from __future__ import print_function

log = open("output.txt", "w")
print('{:02d} {} {} {} {} {}'.format(
                queryID,
                "Q0",
                match[0], # filename
                rank,
                match[1], # score
                config.MY_NAME
            ), file = log)
出现错误:

TypeError: write() argument 1 must be unicode, not str
然后我试着用wb
wb
替换,问题解决了,不再出现错误

log = open("output.txt", "wb")

有人能解释一下这里发生了什么吗?

显示您的
\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu