|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- with open('豆瓣电影TOP250.txt','w',encoding = 'utf-8') as f:
- for each in result:
- f.write(each)
复制代码
这段代码有什么问题吗???
为什么总抛出异常
- File "D:\下载\python\学习\爬虫\爬取豆瓣电影Top250.py", line 62, in main
- with open('豆瓣电影TOP250.txt','w',encoding = 'utf-8') as f:
- TypeError: open() got an unexpected keyword argument 'encoding'
复制代码
我试了,没有出错。是不是前面把open定义成别的函数了。
- result = ['123', '456']
- with open('豆瓣电影TOP250.txt','w',encoding = 'utf-8') as f:
- for each in result:
- f.write(each)
复制代码
|
|