The difference between "320" Python 2.x and 3.x

Source: Internet
Author: User

Through the code porting the error to comb!

1. The difference between print functions

In Python 2.x, you can add spaces or parentheses, but Python 3.x can only be parentheses.

# python 2.x>>> print "processing ..." processing...>>> print ("Processing ...") processing...# python 3.x>>> print ("Processing ...") processing ...

2. Raw_input and input functions

Python 2.x raw_input is similar to the input function in Python 3.x, while the input function in Python 2.x receives a number or a quoted string

# Python 2.x>>> a = Raw_input ("value:") value:alex>>> a ' Alex ' >>> b = input ("value:") Value: "A Lex ">>> B ' Alex ' # Python 3.x>>> a = input (" Value: ") value:alex>>> a ' Alex '

Reference: Differences between raw_input () and input () in python2.x and python3.x

3. Tkinter Module

Python 2.x is Tkinter, but Python 3.x is Tkinter (lowercase)

# python 2.x>>> import tkinter# python 3.x>>> import Tkinter

Reference: Python GUI programming (Tkinter)

4. Division operator

Python 2.x in////are all divisible, but Python 3.x in/representation divided by//means divisible

# python 2.x>>> 77/601>>> 77//601# python 3.x>>> 77/601.2833333333333334>>> Int (77 /60) 1>>> 77//601

The difference between "320" Python 2.x and 3.x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.