buffer转int python"/>
buffer转int python
我有2个API.我从中获取数据.我想为字符串分配特定的代码部分,以便编码时的生活变得更容易.这是代码:
import urllib2
import json
urlIncomeStatement = ':8888'
apiIncomeStatement = urllib2.urlopen(urlIncomeStatement)
dataIncomeStatement = json.load(apiIncomeStatement)
urlFinancialPosition = ':9999'
apiFinancialPosition = urllib2.urlopen(urlFinancialPosition)
dataFinancialPositiont = json.load(apiFinancialPosition)
for item in dataIncomeStatement:
name = item['company']['name']
interestPayable = int(item['company']['interest_payable'])
interestReceivable = int(item['company']['interest_receivable'])
sales = int(item['company']['interest_receivable'])
expenses = int(item['company']['expenses'])
openingStock = int(item['company']['opening_stock'])
closingStock = int(item['company']['closing_stock'])
sum1 = sales + expenses
if item['sector'] == 'technology':
name + "'s interest payable - " + interestPayable
name + "'s interest receivable - " + interestReceivable
name + "'s interest receivable - " + sales
name + "'s interest receivable - " + expenses
name + "'s interest receivable - " + openingStock
name + "'s interest receivable - " + closingStock
print sum1
结果我得到:
Traceback (most recent call last):
File "C:/Users/gnite_000/Desktop/test.py", line 25, in
name + "'s interest payable - " + interestPayable
TypeError: coercing to Unicode: need string or buffer, int found
更多推荐
buffer转int python
发布评论