我得到這個API在Python中運行,並可以得到它來更新.csv文件,但是當我剛剛它打印股票時,我不知道它在哪裏輸出這些數據。這是我的代碼:python println在終端中運行時在哪裏
import urllib
import os
import time
# loop that checks stock prices every 20 seconds and adds them to the file
while 1:
# sometimes this program gives me socket errors so if it does skip this itteration of the loop
try:
stocks = urllib.urlopen('http://finance.yahoo.com/d/quotes.csv?s=JPM+C&f=snl1c6').read()
except IOError:
print ("error reading the socket")
time.sleep(120) #if we don't sleep here loop constently retrys with no delay
continue
print stocks
要將其格式化爲代碼,請在每行代碼前添加4個空格(在您的帖子上按編輯以查看它是如何完成的)。 –