在Python中只作为一个索引计算的列表的总和

2024-05-15 09:52:29 发布

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

嗨,我是一个初学者,我正试图总结一个列表,这是作为一个索引计数

下面的代码是为玩家分发卡片的代码

def component(self):    
    for card in range(2):
        global componentcard
        componentcard= listcard[card]
        t = (re.findall('\d+', componentcard ))
        x=list(t)
        x = [i.split('\n')[0] for i in x] 
        print x[0],

输出给了我['1']['13'],如果我打印索引0,它会给我两个不同的卡值,但作为相同的索引0这给了我一个问题,添加相同的索引有什么想法吗?非常感谢


Tags: 代码inself列表fordef玩家range