如何从其他函数访问数组,列表或字典

基本上,我是通过flask创建一个Web应用程序,我想在其中上传excel文件,将excel文件中的所有数据存储在数组中,或者将其存储在字典中,或者通过字典使用其他函数进行数据处理。我能够读取excel文件并将其存储在数组中,但是我想知道是否有一种方法可以从其他函数访问该数据进行处理。如果可能的话,伪代码会有所帮助。谢谢 !

我在堆栈溢出上看到了其他问题,但是没有确切的答案对我有帮助

from flask_restful import Resource,Api
import openpyxl
from openpyxl import load_workbook
import pandas as pd
import xlrd,xlwt


app = flask(__name__)

api = Api(app)

seller_info = []

@app.route('/',methods=["GET","POST"])
def main():

    if request.method == "POST":

        if request.files:
            excel_file = request.files['excel_file']

            wb = pd.ExcelFile(excel_file)
            excel_data = pd.read_excel(wb,"Summary",header=None,nrows=5)

            global seller_info
            for row in excel_data.iterrows():
                seller_info.append(row[1][1])



        return render_template('main.html',seller_info=seller_info)



    return render_template('main.html')

@app.route('/process',"POST"])
def process():

    return '??'


if __name__ == '__main__':
    app.run(debug=True)

我希望能够从“ seller_info”列表中提取数据,并稍后在“ process”方法中使用它。.我不确定如何做到这一点

hoho1141 回答:如何从其他函数访问数组,列表或字典

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3147818.html

大家都在问