1. Print
Print as function in 3.x
Print ("1", "2") i.e. Output 1 2
2.x print is not a function, so
Print "1", "2" i.e. output 1 2
2. Input and Raw_inputraw_input
Raw_input () treats all input as a string and returns the string type. As a gets ()
Like what:
gender = Raw_input ("what' s your gender? ") " )print(gender) Input: Male output: Male'str'>
Input
Input () under the 3.x version:
Input () is equivalent to eval (raw_input (prompt)) when inputs are not for shaping and floating point types
Where eval evaluates the string str as a valid expression and returns the result of the calculation. Like what:
string conversion to list " [ [up], [3,4], [5,6], [7,8], [9,0]] ">>>type (a)'str'>>>> b = eval (a) Print b[[1, 2], [3, 4], [5, 6], [7, 8], [9, 0]]>>> type (b)'
list
'>
If the input is an integer or a floating-point number, it is returned directly. can be used as input, output template input.
As follows:
c = input ("pleaseinput number")print cprint type (c)
Input: 2.31
Result:'float'>
Python basic syntax