码迷,mamicode.com
首页 > 编程语言 > 详细

Python(30)_统计输入的字符串有多少数字

时间:2018-12-31 00:31:49      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:div   png   NPU   nbsp   inpu   统计   分享图片   com   多少   

#-*-coding:utf-8-*-
‘‘‘
统计用户输入的字符串中有几个数字
‘‘‘
#
numList = [‘0‘,‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘,‘8‘,‘9‘]
s = input(‘请输入字符串:‘)
count = 0
for i in  s:
    if i in numList:
        count +=1
print(count)

技术分享图片


 

Python(30)_统计输入的字符串有多少数字

标签:div   png   NPU   nbsp   inpu   统计   分享图片   com   多少   

原文地址:https://www.cnblogs.com/sunnybowen/p/10201149.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!