Use of input/raw_input in python 2 and 3 [duplicate]

Bind raw_input to input in Python 2:

try:
    input = raw_input
except NameError:
    pass

Now input will return a string in Python 2 as well.


If you’re using six to write 2/3 compatible code then six.input() there points to raw_input() in Python 2 and input() in Python 3.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)