我一直試圖在半小時左右解決這個問題,但是我找不到明確的答案。嘗試從Python中的網站中提取JSON時發生錯誤
它應該返回0,但返回的:
Traceback (most recent call last):
File "/home/lolmaker2002/PycharmProjects/kristwallet/krist.py", line 18, in <module>
print(str(balance(addr)))
File "/home/lolmaker2002/PycharmProjects/kristwallet/krist.py", line 13, in balance
grabbed = json.loads(str(urllib.request.urlopen(node + "/addresses/" + iaddr)))
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我有一些代碼在這裏,我正努力抓住從一些(這是JSON第一,但我想解析)
用於進一步的信息,在下面的代碼節點是http://krist.ceriat.net
def balance(iaddr):
grabbed = json.loads(str(urllib.request.urlopen(node + "/addresses/" + iaddr)))
print(grabbed["address"][1]["balance"])
return grabbed
,我通過它與下面的發送地址:
addr = input('Enter address: ')
print(str(balance(addr)))
另外,如果我通過網絡瀏覽器做一個實際的東西,我得到這樣的:
{"ok":true,"address":{"address":"k5n6r931i1","balance":0,"totalin":903,"totalout":10869,"firstseen":"2016-12-02T21:10:53.000Z"}
你沒有說錯誤是什麼。這很重要。 – Carcigenicate
我添加了一個錯誤和我的完整代碼的圖片。 –
切勿張貼代碼或錯誤的圖片。始終以文字形式發佈一切。 – Carcigenicate