daisenh 2020-03-29 12:06 采纳率: 100%
浏览 583
已采纳

python with open 语法错误

with open 总是用不了,无论怎样都会报错语法错误

import requests
url = 'https://pic.qiushibaike.com/system/pictures/12292/122926302/medium/O6Z3BIKE39GTB6OM.jpg'
img_data = requests.get(url = url).content
with open('./qiutu.jpg','wb') as fp
    fp.write(img_data)

File "", line 4
with open('./qiutu.jpg','wb') as fp
^
SyntaxError: invalid syntax

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-03-29 14:18
    关注

    with open('./qiutu.jpg','wb') as fp
    少了一个冒号
    with open('./qiutu.jpg','wb') as fp:

    问题要是解决的话,请点下采纳

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?