How do I use raw_input in Python 3

后端 未结 8 2398
旧时难觅i
旧时难觅i 2020-11-22 01:39
import sys
print(sys.platform)
print(2**100)
raw_input()

I am using Python 3.1 and can\'t get the raw_input to \"freeze\" the dos pop-

相关标签:
8条回答
  • 2020-11-22 02:36

    A reliable way to address this is

    from six.moves import input
    

    six is a module which patches over many of the 2/3 common code base pain points.

    0 讨论(0)
  • 2020-11-22 02:36

    How about the following one? Should allow you to use either raw_input or input in both Python2 and Python3 with the semantics of Python2's raw_input (aka the semantics of Python3's input)

    # raw_input isn't defined in Python3.x, whereas input wasn't behaving like raw_input in Python 2.x
    # this should make both input and raw_input work in Python 2.x/3.x like the raw_input from Python 2.x 
    try: input = raw_input
    except NameError: raw_input = input
    
    0 讨论(0)
提交回复
热议问题