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

软件和网站开发以及相关技术探讨
回复
mclee
帖子: 6
注册时间: 2006-12-14 10:12

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

#1

帖子 mclee » 2006-12-16 15:57

今天发现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 : 
liugehao
帖子: 61
注册时间: 2006-12-21 11:47

#2

帖子 liugehao » 2006-12-21 14:27

估计是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
>>>
回复