常用函数考察: dict(zip(('a','b','c','d','e'),(1,2,3,4,5))) range(10) sorted([i for i in range
2道外企面试题。1、统计连续字符串出现最大频次#!/usr/bin/envpython#-*-coding:utf-8defmaxblock(x):l=[iforiinx]#或者l=list(x)num=[]n=1foriinrange(len(l)-1):ifl[i]==l[i+1]:n+=1else:n=1num.append(n)printmax(num)maxblock("wae
列表生成式: python内置的用来创建list的生成式。 例子: 要生成list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]可以用list(range(1, 11)): 但如果要生
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号