2016-12-28 16 views
2

我知道有網站對這個問題的許多OCCURENCES,但十幾個,我讀沒能解決簡單的問題:蟒蛇 - 用於遍歷列表 - 返回錯誤「太多值解壓」

for df, ind_source in ["df1", "df2", "df3"], ["investingcom", "bloomberg", "ft"]: 
     print(df+" "+ind_source) 

返回錯誤值:too many values to unpack (expected 2)

什麼是解決這個問題?

+1

您試圖解壓'[「DF1」,「DF2」,「DF3」]',三個項目列表,分爲兩個變量...我覺得這個難度是顯而易見。 – kindall

回答

5
for df, ind_source in zip(["df1", "df2", "df3"], ["investingcom", "bloomberg", "ft"]): 
    print(df+" "+ind_source)