Renamed Modules
Python 3.1Idioms
Data read from a URL, e.g., using urllib.request. urlopen() is returned as a bytes object; use bytes.decode(encoding) to convert it to a string. The bsddb (Berkeley DB library) is gone—but is avaliable from pypi.python.org/pypi/bsddb3. See PEP 3108 (doc.guandang.net) for module renaming details Python 2 Python 3.1 import anydbm import whichdb import BaseHTTPServer import\ SimpleHTTPServer import CGIHTTPServer import __builtin__ import commands import ConfigParser import Cookie import co
okielib import copy_reg import dbm import DocXMLRPCServer import\ SimpleXMLRPCServer import dumbdbm import gdbm import httplib import Queue import repr import robotparser import SocketServer import\ test.test_support import Tkinter import xmlrpc.server import dbm.dumb import dbm.gnu import http.client import queue import reprlib import\ urllib.robotparser import socketserver import test.support import tkinter import\ import urllib urllib.request,\ urllib.parse,\ urllib.error import\ import urllib2 import urlparse import xmlrpclib urllib.request,\ urllib.error import urllib.parse import xmlrpc.client import builtins import subprocess import configparser import http.cookies import http.cookiejar import copyreg import dbm.ndbm import http.server import dbm
Tuples need parentheses in comprehensions; metaclasses are set with the metaclass keyword; import the pickle and string I/O modules directly; lambda doesn’t unpack tuples; set literals are supported (the empty set is set();{} is an empty dict); sorting is fastest using a key function; super() is better; type-testing is more robust with isinstance(); use True and False rather than 1 and 0 Python 2 Python 3.1 L=[x for x in 3, 6] class A: __metaclass__=\ MyMeta class B(MyBase): __metaclass__=\ MyMeta try: import cPickle\ as pickle except ImportError: import pickle try: import cStringIO\ as StringIO except ImportError: import StringIO fn= lambda (a,):\ abs(a) fn= lambda (a, b):\ a+ b S= set((2, 4, 6)) S= set([2, 4, 6]) L= list(seq) L.sort() words.sort( lambda x, y: cmp(x.lower(), y.lower())) class B(A): def __init__(self): super(B, self).\ __init__() if type(x)== X: if type(x) is X: while 1: process() L=[x for x in (3, 6)] class A( metaclass=MyMeta): pass class B(MyBase, metaclass=MyMeta): pass
import pickle
import io
fn= lambda t:\ abs(t[0]) fn= lambda a: abs(a) fn= lambda t:\ t[0]+ t[1] fn= lambda a, b: a+ b S={2, 4, 6} L= sorted(seq) words.sort( key=lambda x: x.lower()) class B(A): def __init__(self): super().\ __init__() if isinstance(x, X): while True: process()

Python3.x和Python2.x的区别_计算机软件及应用_IT/计算机_专业资料。Python3.x和Python2.x的区别编码语法使用2to3将代码移植到PYTHON 3 被重命名或者重新组织的...
Python2.X 和 Python3.X 的区别_计算机软件及应用_IT/计算机_专业资料。Python2.X 和 Python3.X 的区别 1.性能 Py3.0 运行 pystone benchmark 的速度比 Py...
Python3.3.2入门教程_计算机软件及应用_IT/计算机_专业资料。Python3.3.2入门教程本文适合有经验的程序员尽快进入 Python 世界.特别地,如果你掌握 Java 和 Javas...
python3.0 对python2.x 升级后重大语法变动_计算机软件及应用_IT/计算机_专业资料。phthon语法文档python3.0 对 python2.x 升级后重大语法变动 python 2.4 与...
Python 3.0与2.0的用法区别_IT/计算机_专业资料。本文介绍了一些python2.5之后版本的一些语法的使用方法。1.性能 Py3.0 运行 pystone benchmark 的速度比 Py...
Python 3.x与Python 2.x的区别_计算机软件及应用_IT/计算机_专业资料。Python 3.0以后的版本与之前版本的区别,作为参考1.性能 Py3.0 运行 pystone benchmark ...
Mod_python 3.2.8中文手... 65页 免费 python函数中文手册 21页 1下载券Mod_python_3.2.8...
Python 3.3 官方入门指南_计算机软件及应用_IT/计算机_专业资料。官方版本的Python...交互模式 2.2.1. 错误处理 2.2.2. 执行 Python 脚本 2.2.3. 源程序...
Python 3 “负层” 1. 0. Python 1. 2. Python 3. Microsoft Windows 4. Mac OS X 5. Ubuntu Linux 6. 7. Python Shell 8. Python 编辑 1. Python...
Python3中文教程_计算机软件及应用_IT/计算机_专业资料。Python已经是3.1版本了.../usr/bin/python a=2 b="test" c=a+b 运行这行程序会出错,提示你字符串...
热门文档