Python: raw_input() vs input()

2018-07-06  本文已影响0人  Sam_f32a

Syntax

The syntax is as follows for Python v2.x:

mydata=raw_input('Prompt :')

print(mydata)

On Python v2.x:

raw_input is used to read text (strings) from the user.

input is used to read integers.

The syntax is as follows for Python v3.x as raw_input() was renamed to input() :

mydata=input('Prompt :')

print(mydata)

上一篇下一篇

猜你喜欢

热点阅读