python2.7 and python3.X difference

1, print ( "Chinese")

python2.7, being given reasons: py2.7 with ascll code

Resolution: 2.7 head to join and save the file encoded with utf-8

# -*- coding: utf-8 -*-

python3 wrong reasons: py3 with ufu-8 code       

2, input

py2.7 name=raw_input()

py3.x name=input()

3, division

9/2

4 py2 result (take the integer part)

py3 became 4.5

Solve: py2 (from __future__ import division) and py3

Rounded Syntax 2 // 9

 

Guess you like

Origin www.cnblogs.com/zmzzm/p/12005087.html