写入文件Python,错误?

时间:2016-12-02 09:30:46

标签: python python-3.x beautifulsoup

我试着写入文件:

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

f.write(url + '\n' + title + '\n' + email + '\n\n')

但我得到错误:

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

有什么问题?

1 个答案:

答案 0 :(得分:5)

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