Home>Article>Backend Development> The difference between python2.7 and 3.7
Difference 1: Use print syntax
Python2.7 Use print syntax >>> ; print "Hello Python"
Python3.7 Print syntax usage >>> print("Hello Python")
Example: Using double quotes to trigger a SyntaxError exception in Python 3.7.0 Mechanism Prompt Did you mean print("Hello Python3.7")
##print The difference between line wrapping and no line wrapping
python 2.7 print Use "," without line breaks## python 3.7 print Use end=""
Difference 2: raw_input() and input()Python 2.7 raw_input() and input() both exist and can be used raw_input() receives a string input() receives a number int /flot.
Python 3.7 raw_input() does not exist. Only input() exists. The two are merged. Receive any format and return string
Difference 3: Function cmp()
python 2.7 The cmp(x,y) function is used to compare two objects. If x < y returns -1, if x == y returns 0, if
##Difference four: string uppercase and lowercase letter stringsstring.letters: a string containing all letters (uppercase or lowercase)
In Python 3.0, string. ascii_letters.Related recommendations: "
Python Tutorial"
The above is the detailed content of The difference between python2.7 and 3.7. For more information, please follow other related articles on the PHP Chinese website!