2017-11-12 5 views
0

내가 다른 파일에서 키워드 URL을 업데이트하고 URL의 내용을 읽을하려고하지만 오류 아래urlopen 오류 동안

f = open('myfile.txt') 
for line in iter(f): 
    id = line.strip('\n') 
    url_sell = 'https://example.com/getmarketsummary?market='+str(id) 
    df = pd.read_json(url_sell, orient='columns') 

을 던지고 오류

urllib2.URLError: <urlopen error no host given> 
에게 있습니다
+0

오류를 던지는 값을 확인하기 위해'id'를 인쇄 할 수 있습니까? – PRMoureu

답변

0

디버그하려면 try, excep를 사용하십시오.

for line in iter(f): 
    id = line.strip('\n') 
    try: 
     url_sell = 'https://example.com/getmarketsummary?market='+str(id) 
    except: 
     return id