简体   繁体   English

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

[英]Extract multiple numbers from a string without commas

I'm recently trying to use my RFID card's UID but I'd like the UID to be like 11217924711571 instead of [112, 179, 247, 115, 71] . 我最近试图使用我的RFID卡的UID,但我希望UID像11217924711571而不是[112, 179, 247, 115, 71] 11217924711571 [112, 179, 247, 115, 71] I've tried int(re.search(r'\\d+', uid_str).group()) but it only returns 112 . 我尝试过int(re.search(r'\\d+', uid_str).group())但它只返回112 Can somebody please help me? 有人能帮帮我吗?

You could try this: 你可以试试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM