【问题标题】:combining from two lists into one class Python [duplicate]将两个列表组合成一个类 Python [重复]
【发布时间】:2018-10-14 03:45:21
【问题描述】:

基本上,我想要一些类似的东西:

for coin in all_coins["result"] and coin2 in all_coins2["result"]:
    specifiedlist.append(Crypto(coin, coin2)) 

任何帮助我指出正确的功能或格式的方向将不胜感激。

【问题讨论】:

标签: python list class


【解决方案1】:

您可以使用itertools.product 在列表理解中创建排列

from itertools import product
specifiedlist = [Crypto(coin, coin2) in product(all_coins["result"], all_coins2["result"])]

【讨论】:

    猜你喜欢
    • 2015-10-30
    • 1970-01-01
    • 2017-04-12
    • 2022-12-05
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 2013-04-15
    • 2021-07-27
    相关资源
    最近更新 更多