pydev中raw_input()不能正常工作的问题,大家怎么处理的?

pydev中raw_input()不能正常工作的问题,大家怎么处理的?

在eclipse+pydev开发中使用raw_input()时,会在输入的字符串后加上'\r',比如输入'test',而实际得到的是'test\r'。

看了pydev的FAQ,上面的解释是这样的:
http://pydev.sourceforge.net/faq ... _not_work_correctly

Why raw_input() / input() does not work correctly in pydev?

The eclipse console is not an exact copy of a shell... one of the changes is that when you press <ENTER> in a shell, it may give you a \r, \n or \r\n as an end-line char, depending on your platform. Python does not expect this -- from the docs it says that it will remove the last \n (checked in version 2.4), but, in some platforms that will leave a \r there. This means that the raw_input() should usually be used as raw_input().replace('\r', ''), and input() should be changed for: eval(raw_input().replace('\r', '')).

也就是说需要将代码写为raw_input().replace('\r', ''),大家有没有更好的处理方法?
既然文档都这样写了,估计难有更好的方法。

可以自己写个函数把 raw_input 给包装起来。