a="23,56,71,35,28,83,59,91,42,36" m=n=0利用循环遍历编程求上述字符串中奇数之和与偶数之和
b="hello,how are you,python computer"
求一段英文文本b中的单词个数
import re
b="hello,how are you,python computer"
n = re.split('[,\s]',b)
print('单词个数数:', len(n), n)
//运行结果
单词数: 6 ['hello', 'how', 'are', 'you', 'python', 'computer']
c=['100001,张三,1996/7/25',
'100002,李四,1992/5/6',
'100003,王五,1995/11/21',
'100004,赵六,1998/3/23',
'100005,钱七,1995/8/26']
求c中年份最大的同学和年份最小的同学的学号和姓名
import re
c=['100001,张三,1996/7/25',
'100002,李四,1992/5/6',
'100003,王五,1995/11/21',
'100004,赵六,1998/3/23',
'100005,钱七,1995/8/26']
print( '年份最小同学为: {}'.format( min(c, key=lambda x : x.split(',')[2][:4]) ).split(',')[:2] )
print( '年份最大同学为: {}'.format( max(c, key=lambda x : x.split(',')[2][:4]) ).split(',')[:2] )
//运行结果
['年份最小同学为: 100002', '李四']
['年份最大同学为: 100004', '赵六']