Home  >  Article  >  Backend Development  >  The difference between raw_input() and input()

The difference between raw_input() and input()

巴扎黑
巴扎黑Original
2016-12-09 14:13:191350browse

text = raw_input("Enter a string:") treats the user's input as a string (str), that is, text is a string.

num = input("Enter a number:") treats the user's input as a number (int or float), that is, num is a number.

Test:

>>>text = raw_input("Enter a string:")

Enter a string: hello

>>> print type(text)

Output: < ;type 'str'>

>>>num = input("Enter a number:")

Enter a number:12.4

>>>print type(num)

output:


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Python thread sortingNext article:Python thread sorting