我从 urllib2 得到 404。尽管该链接在我的浏览器中运行良好...
import urllib2
import numpy
import scipy.stats
import csv
import httplib
f1 = urllib2.urlopen("http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=01&b=1&c=2010&d=01&e=01&f=2011&g=d&ignore=.csv")
f2 = urllib2.urlopen("http://ichart.finance.yahoo.com/table.csv?s=APPL&a=01&b=1&c=2010&d=01&e=01&f=2011&g=d&ignore=.csv")
a = numpy.genfromtxt(f1, delimiter=',', skip_header=0, names=True);
b = numpy.genfromtxt(f2, delimiter=',', skip_header=0, names=True);
prs = scipy.stats.pearsonr(a['Open'], b['Open'])
print prs