首页 > 解决方案 > 如何访问函数结果中的记录或 frecord 变量,以便我可以使用它来函数提交?

问题描述

我试图使记录变量成为全局变量,之后,我试图在提交函数中使用它,但它给出了一个错误“未定义记录”。谁能帮我了解一下情况?

下面我有两个函数(resultsubmit),并且记录变量基本上在结果​​中有一些值,我想在提交中访问它。任何人都可以帮忙吗?

    def submit(): ## this function will use to add stock.
        for i in f_record:                           (SUBMIT FUNCTION )
            for j in i:
                if(j==name1.get()):
                    p=int(i[3]) * quantity1          
        price=p

    def result(): # This function will use to see if the stock is added or not. Also to see the present stock                                              (RESULT FUNCTION)
        stock=sqlite3.connect('Super Store Stock')
        c=stock.cursor()
        c.execute('SELECT * FROM y')   ##this will use to select all elements from table we have created 
        global record
        record=c.fetchall()
        stock.commit()
        stock.close()
        return

标签: pythonpython-3.xsqlite

解决方案


推荐阅读