1,print (print)
Python2 version:
print ' A ' outputs a string
Print a outputs a variable
Python3 version:
Print (' a ') outputs a string
Print (a) output a variable
2, input Python3 cancels the input mode of raw_input, and uses input to receive input.
Python2 version:
Raw_input is in the Python2 version, and all input from the user is treated as a string.
Input can only receive integer types.
Python3 version:
No raw_input function, using the input function to receive processing.
What the user is typing is what. For example, you enter a string:
n = input (' Please input somthing: ')
The user input string, ' ABCDEFG ', needs to be quoted in order to represent the string, otherwise the Python interpreter will consider it to be a variable.
User Input Number: 123
User input variable: a
3, list sort by using sort
The list in Python2 can be both a string and a number, then sort using sort, using Ascall code when sorting.
List1 = [' A ', ' B ', 123]
List1.sort ()
Print List1
Run Result: [123, ' A ', ' B ']
The list in Python3 must be a pure number to sort.
List1 = [' A ', ' B ', 123]
List1.sort ()
Operation Result:
Traceback (most recent):
File "c:/users/administrator/pycharmprojects/20180119/index.py", line A, in <module>
List1.sort ()
TypeError: ' < ' not supported between instances of ' int ' and ' str '
Continuous UPDATE!!!
The difference between Python2 and python3 (continuous update)