The difference between python2.7 and 3.7

藏色散人
Release: 2019-07-03 15:57:27
Original
8345 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template