分页: 1 / 1

[问题]eclipse 学习python中len函数问题

发表于 : 2006-12-16 15:57
mclee
今天发现eclipse做len()测量长度的时候发现总是多算一位,而且无法break:

代码: 全选

while True:
    s = str(raw_input('Enter something : '))
    if s == 'quit':
      break
    print 'Length of the string is', len(s)
print 'Done' 
结果:

代码: 全选

Enter something : quit
Length of the string is 5
Enter something : 

发表于 : 2006-12-21 14:27
liugehao
估计是eclipse有关
>>> while True:
... s = str(raw_input('Enter something : '))
... if s == 'quit':
... break
... print 'Length of the string is', len(s)
...
Enter something : sd
Length of the string is 2
Enter something : sdfsdf
Length of the string is 6
Enter something : quit
>>>