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

The difference between raw_input() and input()

巴扎黑
Release: 2016-12-09 14:13:19
Original
1421 people have browsed it

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 of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template