我正在尝试执行这段代码,该代码应该成功地将我的json字符串转换为正确的dict文件,因为显然请求libary需要以这种方式格式化...
Headers="""{
":authority":"coinmarketcap.com",
":method":"POST",
":path":"/login",
":scheme":"https",
"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"accept-encoding":"gzip, deflate, br",
"accept-language":"en-US,en;q=0.9",
"cache-control":"max-age=0",
"content-length":"743",
"content-type":"application/x-www-form-urlencoded",
"cookie":\""""+CookieDough+"""\",
"origin":"https://coinmarketcap.com",
"referer":"https://coinmarketcap.com",
"upgrade-insecure-requests":"1",
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
}"""
print(json.loads(Headers))
但是当我运行它时,我收到以下错误:
Traceback (most recent call last):
File "C:\Users\Master\Documents\CoinMarketCapScraperTool\CoinMarketCapScraperTool", line 39, in <module>
print(json.loads(Headers))
File "C:\Users\Master\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\Users\Master\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Master\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 17 column 1 (char 1132)
我还尝试运行第一个Headers变量,但是使用\&#34;添加在字符串的开头和结尾处。但它给了我以下错误:
json.decoder.JSONDecodeError: Invalid control character at: line 1 column 3 (char 2)
但是当我添加
时strict=False
,我收到以下错误:
AttributeError: 'str' object has no attribute 'read'
我生气了请帮助我lol