Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 引用二维数组中的每个变量_Python_Arrays_Sql Server - Fatal编程技术网

Python 引用二维数组中的每个变量

Python 引用二维数组中的每个变量,python,arrays,sql-server,Python,Arrays,Sql Server,我有一个脚本,可以访问MSSQL数据库中列中的记录。然后我循环这些来做一些事情。例如,列ASXCode被传递给我的For循环 我希望能够从表2d数组中检索2列,然后以xcode和Sector的形式访问每个变量。 如何引用示例2中的每个变量 例1 例2 现在有两个元素需要迭代,比如 for code, sector in ASXCodes: print(code) print(sector) conn.close() cur.execute('SELECT ASXCode, SE

我有一个脚本,可以访问MSSQL数据库中列中的记录。然后我循环这些来做一些事情。例如,列ASXCode被传递给我的For循环

我希望能够从表2d数组中检索2列,然后以xcode和Sector的形式访问每个变量。 如何引用示例2中的每个变量

例1 例2
现在有两个元素需要迭代,比如

for code, sector in ASXCodes:
    print(code)
    print(sector)
conn.close()
cur.execute('SELECT ASXCode, SECTOR FROM tbl_Company')

for code, sector in cur:
  ....
顺便说一句,你可能想用

for code, sector in ASXCodes:
    print(code)
    print(sector)
conn.close()
cur.execute('SELECT ASXCode, SECTOR FROM tbl_Company')

for code, sector in cur:
  ....
因为它可能会大大提高可读性