根据for循环中的变量字符串指定变量名

2024-09-30 08:22:04 发布

您现在位置:Python中文网/ 问答频道 /正文

dblist = ('database1', 'database2', 'database3', 'database4', 'database5', 'database6', 'database7') 
for db in dblist:
    cursor = conn.cursor()
    cursor.execute("select SYSTEM from automation/awdclient where db = " + "'" + db + "'" + "")
    for row in cursor:
        activesystem.db = row[0]
    cursor.close
    conn.close
print activesystem.database1
print activesystem.database2

我要做的是从数据库中检索系统名。我想分配一个与系统名相等的变量,用变量名系统。随便数据库字符串是。在


Tags: in数据库forcloseexecutedb系统conn

热门问题