用PYTHON和STREMLIT从GITHUB加载JSON数据
大家好,提前感谢你们的帮助 我一直在使用Streamlight和Python进行开发,现在我想在Heroku中部署所有的想法 这是我第一次在heroku中部署应用程序。我想从github加载json文件,因为我想每周用statsbomb数据更新应用程序 到目前为止,我一直在从我的计算机加载json文件,请查看随附的代码:用PYTHON和STREMLIT从GITHUB加载JSON数据,python,json,streamlit,Python,Json,Streamlit,大家好,提前感谢你们的帮助 我一直在使用Streamlight和Python进行开发,现在我想在Heroku中部署所有的想法 这是我第一次在heroku中部署应用程序。我想从github加载json文件,因为我想每周用statsbomb数据更新应用程序 到目前为止,我一直在从我的计算机加载json文件,请查看随附的代码: import streamlit as st import pandas as pd import json import os from pandas import json
import streamlit as st
import pandas as pd
import json
import os
from pandas import json_normalize
from flatten_json import flatten
import matplotlib.pyplot as plt
from matplotlib.patches import Arc
import numpy as np
from PIL import Image
import urllib, json
### NAME OF THE APP ###
x = st.sidebar.header(' Analytics') # You are pointing at the wrong URL, which will return a 404 instead of valid JSON. That in turn cannot be parsed by json.loads
, leading to the JSONDecodeError
Change your url
variable code to:
url = (
"https://raw.githubusercontent.com/statsbomb/open-data/master/data/matches/11/"
+ file_to_charge
)
将streamlight导入为st
作为pd进口熊猫
导入json
导入操作系统
从pandas导入json_规范化
从展平\u json导入展平
将matplotlib.pyplot作为plt导入
从matplotlib.patches导入圆弧
将numpy作为np导入
从PIL导入图像
导入urllib、json
###应用程序的名称###
x=st.sidebar.header('Analytics')#您指向了错误的URL,该URL将返回404而不是有效的JSON。这反过来又不能被json.load解析,从而导致JSONDecodeError
将url
变量代码更改为:
TLDR:你的问题是什么?我无法从github加载json文件,我需要它(2º代码),问题是3º代码。非常感谢,非常感谢!我会努力,我会对你说。再次感谢