设为首页收藏本站

Crossin的编程教室

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

【每日一坑 3】 找数字

[复制链接]

9

主题

2

好友

164

积分

注册会员

Rank: 2

楼主
发表于 2021-4-10 12:57:09 |显示全部楼层
本帖最后由 ZZZZZ 于 2021-4-11 13:16 编辑
  1. text = “aAsmr3idd4bgs7Dlsf9eAF”
  2. b = “”
  3. c = “”
  4. for a in text:
  5.     if a in ['0','1','2','3','4','5','6','7','8','9']:
  6.         b += a
  7.     else:
  8.         c += str(a)
  9. print(b,c)
  10.         
复制代码
回复

使用道具 举报

9

主题

2

好友

164

积分

注册会员

Rank: 2

沙发
发表于 2021-5-2 09:46:54 |显示全部楼层
text = input()
new_text = []
for i in text:
  if i in list(range(0, 9)):
    new_text.append(i)
for i in new_text:
  print(i)
回复

使用道具 举报

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

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

GMT+8, 2024-5-4 12:07 , Processed in 0.016448 second(s), 23 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部