设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
楼主: crossin先生
打印 上一主题 下一主题

【每日一坑 3】 找数字

[复制链接]

0

主题

0

好友

14

积分

新手上路

Rank: 1

楼主
发表于 2017-6-7 23:22:19 |显示全部楼层
# 3
# find all the numbers and combine them to a new string
import re
text = "aAsmr3idd42bgs72Dlsf23eAF"
# regular expression find all the numbers which length greater equal than 1
nums = re.findall("[0-9]+",text)
# check the output
print nums
# join them together
new_str = ''.join(nums)
# check the type of new string
print type(new_str)
# print new string
print new_str
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-5 02:33 , Processed in 0.026329 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部