练习

2015-10-07 0 151
练习
#输出第一个参数中的且在其他参数中都出现过的字符,出现几次输出几次
#!/usr/bin/python
def intersect(*args):
	print 'args[0]:',str(args[0])
	print 'args[1:]:',str(args[1:])
	ress = []
	for x in args[0]:
		for other in args[1:]:
			if x not in other:
				break
			else:
				ress.append(x)
	return ress

s1 = 'spam'
s2 = 'scam'
s3 = 'sobm'
pp = intersect(s1,s2,s3)
print pp

遇见资源网 python 练习 http://www.ox520.com/15827.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务