类型str不支持缓冲区API

时间:2016-09-27 03:17:43

标签: api buffer python-3.4

当我运行代码时,我收到错误“主循环失败类型str不支持缓冲区API”:

    import time
    import urllib
    from urllib.request import urlopen

    sp500short = ['a', 'aa', 'aapl', 'abbv', 'abc', 'abt', 'ace', 'aci', 'acn', 'act', 'adbe', 'adi', 'adm']

    def yahooKeyStats(stock):
        try:
            sourceCode = urlopen('http://www.advfn.com/stock-market/NYSE/'+stock+'/financials').read()
            pbr = sourceCode.split("Price/Book Ratio</td><td class='s' align='right'>")[1].split("</td>")[0]

            print ("Price to book ratio:",pbr)

        except Exception,e:
            print ("Failed in the main loop", str(e))

    for eachStock in sp500short:
        yahooKeyStats(eachStock)

0 个答案:

没有答案