如下所示:
# -*- coding: utf-8 -*-
# 要求:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
def count(s):
count_a=count_z=count_o=count_s=0
for i in s:
if (ord(i)>=97 and ord(i)=65 and ord(i)=48 and ord(i)<=57:
count_z=count_z+1
elif ord(i)==32:
coun
编写二个函数,其中一个函数func1完成功能为:接收字符串参数,返回一个元组,其中第一个元素为字符串中大写字母个数,第二个元素为字符串中小写字母个数;另一个函数func2的功能为随机产生一个长度不小于10的字符串.调用这二个函数,要求能统计出func2产生的字符串中大小字母的个数。
import random,string;
def func1():
a=int(input("请输入随机生成的字符串长度:"))
b=[int(i) for i in range(0,a+1)]