【问题标题】:upload .gpx file Streamlit Python上传 .gpx 文件 Streamlit Python
【发布时间】:2021-07-06 07:27:18
【问题描述】:

我使用 python 制作了一个 Streamlit 应用程序,可以在其中拖放 gpx 文件。

import streamlit as st 
file = st.file_uploader("Upload a strava file (gpx)", type=["gpx"],accept_multiple_files=False)

但是,使用 gpxpy 包打开 InMemoryUploadedFile 是不可能的。给我一个 KeyError:3655

import gpxpy
gpx = gpxpy.parse(file)

有人可以帮我吗?

【问题讨论】:

    标签: python gpx streamlit


    【解决方案1】:

    请尝试:

    import streamlit as st
    import gpxpy
    
    file = st.file_uploader("Upload a strava file (gpx)", type=["gpx"], accept_multiple_files=False)
    
    if uploaded_file is not None:
        gpx = gpxpy.parse(uploaded_file)
    

    还请确保 streamlit 和 gpxpy 都更新到最新版本并且 gpx 文件没有损坏

    【讨论】:

    • 您好,感谢您的回答。这行不通。我的代码不完整,我已经有了 If 语句。问题是它无法处理内存中的文件..
    猜你喜欢
    • 1970-01-01
    • 2021-01-22
    • 2013-12-20
    • 2020-12-06
    • 2022-11-27
    • 2022-11-14
    • 1970-01-01
    • 2021-12-11
    • 2021-06-19
    相关资源
    最近更新 更多