Irene_f
Irene_f
2017-09-03 03:35

unsupported operand type(s) for -

  • python
  • typeerror
import requests
from matplotlib import pyplot as plt
url='https://api.github.com/search/repositories?q=language:python&sort=stars'
r=requests.get(url)
response_dict=r.json()
respo_dicts=response_dict['items']
names,stars=[],[]
for r in respo_dicts:
    names.append(r['name'])
    stars.append(r['stargazers_count'])
plt.bar(names,stars,c='blue')
plt.title('gh_repo',fontsize=20)
plt.xlabel('py projects',fontsize=14)
plt.ylabel('star nums',fontsize=14)
plt.show()

报错 TypeError: unsupported operand type(s) for -: 'str' and 'float'
我查了names里的元素类型都是str,stars里的都是int
请问为什么会报错?这个错误是什么意思?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换