Home >Backend Development >Python Tutorial >How Did Python 3 Replace `raw_input()` and What Does `input()` Do Now?
Python 3: Using 'input()' to Replace 'raw_input()'
In Python 2, the 'raw_input()' function was used to read input from the console without parsing it. However, in Python 3, 'raw_input()' is no longer available.
To understand the reason behind this change, we refer to the official documentation for Python 3.0:
"What's New in Python 3.0
Builtins:
Therefore, in Python 3, the 'input()' function now replaces the former 'raw_input()' function. It takes input as a string and converts it to Unicode based on the encoding specified by 'sys.stdin.encoding'. This change eliminates the potential for misinterpretation between text and binary data when reading from the terminal.
The above is the detailed content of How Did Python 3 Replace `raw_input()` and What Does `input()` Do Now?. For more information, please follow other related articles on the PHP Chinese website!