【问题标题】:How do I import data and packages from REST APIs如何从 REST API 导入数据和包
【发布时间】:2021-03-24 18:39:00
【问题描述】:

我目前正在尝试通过 coursera 学习 Python,并且正在尝试运行代码,但是在尝试安装 nba_api 时遇到了错误。下面我粘贴了我的代码

!pip install nba_api  

# I get an 'invalid syntax error' here ^^  

import pandas as pd
import matplotlib.pyplot as plt

x={'a':[11,21,31],'b':[12,22,32]}

print(x)

df=pd.DataFrame(x)
print(type(df))

print(df.head())

from nba_api.stats.static import teams
import matplotlib.pyplot as plt

任何想法我在这里做错/错过了什么?

【问题讨论】:

    标签: python pandas spyder rest coursera-api


    【解决方案1】:

    ! 是调用仅在 REPL 中的 shell 的简写。你不能在 Python 文件中使用它。

    你应该把你的代码放在一个包中并且依赖于 nba_api,当有人安装你的包时,nba_api 包也会被安装。

    【讨论】:

      猜你喜欢
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      • 2019-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多