浏览 7668 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-11-23
width = input('Please enter width: ') 这条语句 为什么我在 IDLE下运行就是 正确的 而在pydev+eclipse 下,一运行然后输入 数字 打个回车就会出错呢? 只能用raw_input来代替. 错误显示 SyntaxError: unexpected EOF while parsing 文档中 This function is not safe from user errors! It expects a valid Python expression as input; if the input is not syntactically valid, a SyntaxError will be raised 在这里not syntactically 指的是什么 呢 ? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-11-24
已经解决,断点调试后显示,编译器每次都多读一个"/r",郁闷。
Fabio Zadrozny 的回答是: Nope, this is a python bug mixed with a bad specification on how a shell is supposed to behave. Usually shells put a '\n' when you press enter, but the Eclipse console puts '\r\n' and python does not handle it well, as this is not specified anywhere, and does not seem such awkward, my feeling is that it's a python bug, but you can surely argue the other way... so, you can submit a bug to eclipse.org and python.org and see who'll fix it... (or you can handle it in your program). Cheers, Fabio |
|
返回顶楼 | |
发表时间:2006-11-24
在C的时代,\r只是回车,并不换行,如果你用打字机,那么\r的意思是指打字头回到行首,而非换到下一行。\r\n才是所有平台上公认的加车换行标记。Python是C语言写的,自然会这么想。呵呵。
|
|
返回顶楼 | |