__MagicPower
Do one thing and do it best!

导航

 
while i < len(myString):
    print 'character %d is:'%myString[i]


length = len(myString)

while i < length:
    print 'character %d is:'%myString[i]


for otherchar in myInput[1:]:
    if otherchar not in alphas + nums:


alphnums = alphas + nums
for otherchar in myInput[1:]:
    if otherchar not in alphnums:

如果在循环里面使用len则会导致多次调用len函数会导致效率低下

 

如果not in alphas + nums 则每次判断都会进行加法 也会导致效率低下

posted on 2015-12-02 13:56  __MagicPower  阅读(158)  评论(0编辑  收藏  举报