python - Python-MySQL:如何在 Python 中的 2 个不同函数上共享或重用单个变量?
问题描述
我有 2 个不同的函数,它们分别进行查询并将数据插入到 2 个不同的 MySQL 表中。如何在第二个函数中重用变量(转换)?
def getRows():
convert = str(rows)
def getDetails():
productId = convert
解决方案
这里:
#function call
converty = getRows()
getDetails(converty)
def getRows():
convert = str(rows)
return convert
def getDetails(convert):
data = aliexpress.get_product_details(['productUrl', 'discount', 'evaluateScore',
'volume', 'packageType', 'lotNum', 'validTime', 'storeName', 'storeUrl','allImageUrls'], convert)
productId = convert
推荐阅读
- python - 如何在不影响 0 权重神经元的情况下计算 FLOPs 和 Params?
- c++ - C++ 异常框架是否需要内核支持?
- typescript - Type Guard Typescript 未正确推断函数剩余参数
- python - 如何限制 jsonschema 中未声明的添加字段
- reactjs - 反应路由器dom的问题
- html - 如何使用管道过滤到 Ionic 中的两个列表
- asp.net-core - ASP.NET Core,AddScoped 不保留具有相同请求的数据
- android - 如何从选项卡式活动中片段的 Textview/Button 开始新活动
- apache-camel - 如何在仅限 Java 的 Camel Main 中配置 REST 属性?
- c# - 等待加载程序的硒消失了