there are two common input function,it's raw-input() and input(),thier function is receive the input from console ,but they have received and operated the data ,which is different. Then let's discuss the different of them.
#! usr/bin/env python
# coding = utf-8
'''
this function is test input function and raw_input function,of course this also test the comments,
include single-line comments,local comments and the block comments.
'''
def fun_str():
a = input("str_Input:") # if you input a str ,then there will report a syntax error
print(a)
b = raw_input("str_raw_input:")
print(b)
def fun_int():
a = input("int_Input:")
print(a)
print(str(type(a)))
b = raw_input("int_str_raw_input:")
print(b)
print(str(type(b)))
#fun_str()
fun_int()
let's see the code,you could input 123
the result is :
int_Input:123
<type 'int'>
then you could input 123
int_str_raw_input: 123
123
<type 'str'>
if you annotate the “fun_int” ,and use function fun_str():
if you could input abc
then there will be an error ,becasue the input() requiers what you have input is a legitimate expression,so the "abc"
not transfer the type of int . so when you want to input "abc",you should use expression "input("abc")" or "input('abc')".
As shown above ,we can see that raw_input return a str whatever you input , but input() return the data type that you input.