[英]Python: requests.get ignores the last record
這是我的代碼:
response = requests.get(apiurl+'api/v1/watch/services',
auth=(apiuser,apipass), verify=False, stream=True)
for line in response.iter_lines():
try:
data = json.loads(line.decode('utf-8'))
pprint.pprint(data)
except Exception as e:
pprint.pprint(e)
pass
請注意stream=True
。
問題是,當我有a
b
c
d
上的輸入時,腳本只是輸出a
b
和c
。 然后,當e
輸入時,腳本輸出d
。
我究竟做錯了什么?
好,所以答案對我來說有點出乎意料。
將python從3.4更新到3.5有幫助,沒有其他改變。
希望這個答案可以幫助其他人解決這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.