Python编写一个函数,统计字符串中非字母的符号个数
字符串从键盘输入;
例如:输入abcd123
输出结果为3
代码:
def statistical(zfc):
sz=0
for i in zfc:
if i.isdigit():
sz+=1
print(‘输出结果为{}’.format(sz))
statistical(input(“字符串从键盘输入:”))
运行截图:
Python编写一个函数,统计字符串中非字母的符号个数
字符串从键盘输入;
例如:输入abcd123
输出结果为3
代码:
def statistical(zfc):
sz=0
for i in zfc:
if i.isdigit():
sz+=1
print(‘输出结果为{}’.format(sz))
statistical(input(“字符串从键盘输入:”))
运行截图: