buffer转int python

编程入门 行业动态 更新时间:2024-10-12 03:20:07

<a href=https://www.elefans.com/category/jswz/34/1771223.html style=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

本文发布于:2024-03-06 15:23:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1715667.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:buffer   int   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!