>> print("Hello Python") and so on."/> >> print("Hello Python") and so on.">

Home>Article>Backend Development> The difference between python2.7 and 3.7

The difference between python2.7 and 3.7

藏色散人
藏色散人 Original
2019-07-03 09:09:57 8257browse

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 strings

string.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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn