[英]how to download JSON file using Python from a URL with authentication key
[英]How to download file from url using python in the same format?
我必須下載文件,我可以使用“ urllib2”來完成文件。
response = urllib2.urlopen(URL)
file=response.read()
但是,我無法逐行閱讀。
這是我嘗試過的:
response = urllib2.urlopen(URL)
for line in response.read():
#do stuff
所有文件都是一行。 原始文件被換行了。
有人可以告訴我如何將文件更改為原始文件嗎?
只是分割輸出:
response = urllib2.urlopen(URL)
lines=response.read().splitlines()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.