从字符串中提取多个数字而不使用逗号

时间:2017-04-01 12:36:35

标签: python

我最近试图使用我的RFID卡的UID,但我希望UID与11217924711571而不是[112, 179, 247, 115, 71]相似。我尝试了int(re.search(r'\d+', uid_str).group()),但它只返回112。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

old = [112, 179, 247, 115, 71]
new = ''.join(map(str, old)) # will be a str
new_int = int(new) # if you need it to be an integer, convert it