将json响应保存在python中

问题描述 投票:1回答:1

我正在使用此代码通过python从我的网站获取信息,这就像一个超级按钮,但是我可以将此输出保存到变量或至少保存到json或txt文件中

import pycurl
def getUserData():
   c = pycurl.Curl()
   c.setopt(pycurl.URL, 'https://api.github.com/users/braitsch')
   c.setopt(pycurl.HTTPHEADER, ['Accept: application/json'])
   c.setopt(pycurl.VERBOSE, 0)
   c.setopt(pycurl.USERPWD, 'username:userpass')
   c.perform()
getUserData()
python json pycurl
1个回答
2
投票

这里不要使用curl; Python附带了电池,尽管它的API仅比pycurl好一点。

© www.soinside.com 2019 - 2024. All rights reserved.