Each new version of ①python will add new features or make some changes to the original functionality. Some of the changes are not compatible with the old version, that is, in the current version of the code to run normally, to the next version of the run may not be normal
② from Python 2.7 to Python 3.x there are some incompatible changes, such as the string in 2.x using ' xxx ' to denote the str,unicode string with u ' xxx ' for Unicode, and in 3.x, all strings are considered Unicode, so Write U ' xxx ' and ' xxx ' are exactly the same, and in 2.x the ' xxx ' str must be written as B ' xxx ' to represent the binary string.
To directly upgrade the code to 3.x is more aggressive, because there are a lot of changes need to test. Instead, you can test some of the 3.x features in part of the code in version 2.7, and if there is no problem, migrate to 3.x later.
③python provides a __future__ module to import the next new version of the feature into the current version, so we can test some of the features of the new version in the current release. Examples are as follows:
④ in order to accommodate the new string representation of Python 3.x, in the 2.7 version of the code, you can use the new syntax for Python 3.x by unicode_literals: The default encoding in Python3 is Unicode and the prefix U is canceled. If the code is to be compatible with PYTHON2/3
So, when using Django, importing-from __future__ import unicode_literals in models.py is intended to be version compatible
python great God, in his side bought a lot of Python tutorials, 0 basic entry-level, business development, but the most I am happy is actually have a Python play the plane game, I encountered problems before all the screen inside. SOURCE + screen + Notes + homework, suitable for 0 basic learning. paid to send Oh qq:1929665267 (memo material) information about 2 g of Python electronic books, popular books are in the inside, Python 0 basics, algorithms, artificial intelligence, operational dimensions, testing, large data, etc.
more than 50 g of the classic video tutorials include pytgame game development, reptiles, Python operation, framework development, Python cloud computing, large data, Python enterprise combat development
2018 ~HTML5+CSS3 Video Tutorial (all 227 lectures) (The following picture shows only part of the information), want to be quick.