写入文件Python,错误?

Mis*_*rPi -1 python beautifulsoup python-3.x

我试着写入文件:

 f = open('parsed.txt', 'w')

f.write(url + '\n' + title + '\n' + email + '\n\n')
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

Traceback (most recent call last):
  File "C:/Users/Brand Cream/AppData/Local/Programs/Python/Python35/index.py", line 122, in parsePage
    f = open('parsed.txt', 'w')
TypeError: open() takes 1 positional argument but 2 were given
Run Code Online (Sandbox Code Playgroud)

怎么了?

Pie*_*rre 5

您可能open在代码的其他位置调用了一个函数,该函数只接受一个参数.这就是您收到此错误的原因.