Skip to main content
 首页 » 编程设计

Python之FOR 循环如何在 python 中工作

2025年05月04日11daizhj

<分区>

我有以下 Python 代码,我不确定这里的 for 循环是如何工作的。

cur.execute("SELECT CUST_ID, COMPANY, LASTNAME, CITY, STATE FROM  
mytable")                             
 
colnames = [desc[0] for desc in cur.description]       

这是如何工作的?

[desc[0] for desc in cur.description]    

什么是desc[0]?