Python raw_input() limit with Mac OS X Terminal?

北战南征 提交于 2020-01-03 15:50:13

问题


I wrote a python script and have been running it in terminal on Mac OS X snow leopard using python2.6. I used raw_input() to import text in several places, but I seem to reach a limit where it will no longer accept any more characters.

Is this a limit in python raw_input() or is this something to do with Terminal or Mac OSX?

Is there a better way to have the user input larger amounts of text in python?


回答1:


I'd say it's a limitation/bug with the OSX Terminal - try running the script with input via IDLE and see whether you still hit the same problem.

As for better ways of dealing with large input - it totally depends on your requirements but some ways could be:

  • Import text from a file
  • Create some kind of GUI/frontend to handle text input via more user friendly controls



回答2:


I had this same experience, and found python limits the length of input to raw_input if you do not import the readline module. Once I imported the readline module, it lifted the limit (or at least raised it significantly enough to where the text I was using worked just fine).



来源:https://stackoverflow.com/questions/7357007/python-raw-input-limit-with-mac-os-x-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!