第一次完美运行
This commit is contained in:
16
source/aboutme.rst
Normal file
16
source/aboutme.rst
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
===============
|
||||||
|
关于我们
|
||||||
|
===============
|
||||||
|
|
||||||
|
*关于译者*
|
||||||
|
|
||||||
|
* 网名: 一刀
|
||||||
|
* Email: yidao620@gmail.com
|
||||||
|
* 博客: http://yidao620c.iteye.com/
|
||||||
|
* GitHub: https://github.com/yidao620c
|
||||||
|
|
||||||
|
*主要贡献者*
|
||||||
|
|
||||||
|
1. 张三(zhangsan@gmail.com)
|
||||||
|
2. 李四(lisi@gmail.com)
|
||||||
|
3. 王五(wangwu@gmail.com)
|
||||||
18
source/c100/p101_unpack_sequence_into_separate_variables.rst
Normal file
18
source/c100/p101_unpack_sequence_into_separate_variables.rst
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
===============================
|
||||||
|
解压序列赋值给多个变量
|
||||||
|
===============================
|
||||||
|
|
||||||
|
----------
|
||||||
|
问题
|
||||||
|
----------
|
||||||
|
You have an N-element tuple or sequence that you would like to unpack into a collection of N variables.
|
||||||
|
|
||||||
|
----------
|
||||||
|
解决方案
|
||||||
|
----------
|
||||||
|
Any sequence (or iterable) can be unpacked into variables using a simple assignment operation. The only requirement is that the number of variables and structure match the sequence. For example:
|
||||||
|
|
||||||
|
----------
|
||||||
|
讨论
|
||||||
|
----------
|
||||||
|
Unpacking actually works with any object that happens to be iterable, not just tuples or lists. This includes strings, files, iterators, and generators. For example:
|
||||||
18
source/c100/p102_unpack_elements_from_iterables.rst
Normal file
18
source/c100/p102_unpack_elements_from_iterables.rst
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
================================
|
||||||
|
解压可迭代对象赋值给多个变量
|
||||||
|
================================
|
||||||
|
|
||||||
|
----------
|
||||||
|
问题
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
|
|
||||||
|
----------
|
||||||
|
解决方案
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
|
|
||||||
|
----------
|
||||||
|
讨论
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
18
source/c200/p201_split_string_on_multiple_delimiters.rst
Normal file
18
source/c200/p201_split_string_on_multiple_delimiters.rst
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
=========================
|
||||||
|
使用多个界定符分割字符串
|
||||||
|
=========================
|
||||||
|
|
||||||
|
----------
|
||||||
|
问题
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
|
|
||||||
|
----------
|
||||||
|
解决方案
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
|
|
||||||
|
----------
|
||||||
|
讨论
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
18
source/c200/p202_match_text_at_start_end.rst
Normal file
18
source/c200/p202_match_text_at_start_end.rst
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
======================
|
||||||
|
字符串开头或结尾匹配
|
||||||
|
======================
|
||||||
|
|
||||||
|
----------
|
||||||
|
问题
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
|
|
||||||
|
----------
|
||||||
|
解决方案
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
|
|
||||||
|
----------
|
||||||
|
讨论
|
||||||
|
----------
|
||||||
|
todo...
|
||||||
18
source/chapters/p100_data_structures_algorithms.rst
Normal file
18
source/chapters/p100_data_structures_algorithms.rst
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
=============================
|
||||||
|
第一章:数据结构和算法
|
||||||
|
=============================
|
||||||
|
|
||||||
|
Python provides a variety of useful built-in data structures, such as lists, sets, and dictionaries.
|
||||||
|
For the most part, the use of these structures is straightforward. However,
|
||||||
|
common questions concerning searching, sorting, ordering, and filtering often arise.
|
||||||
|
Thus, the goal of this chapter is to discuss common data structures and algorithms
|
||||||
|
involving data. In addition, treatment is given to the various data structures contained
|
||||||
|
in the collections module.
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
../c100/*
|
||||||
18
source/chapters/p200_strings_and_text.rst
Normal file
18
source/chapters/p200_strings_and_text.rst
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
=============================
|
||||||
|
第二章:字符串和文本
|
||||||
|
=============================
|
||||||
|
|
||||||
|
Python provides a variety of useful built-in data structures, such as lists, sets, and dictionaries.
|
||||||
|
For the most part, the use of these structures is straightforward. However,
|
||||||
|
common questions concerning searching, sorting, ordering, and filtering often arise.
|
||||||
|
Thus, the goal of this chapter is to discuss common data structures and algorithms
|
||||||
|
involving data. In addition, treatment is given to the various data structures contained
|
||||||
|
in the collections module.
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
../c200/*
|
||||||
13
source/copyright.rst
Normal file
13
source/copyright.rst
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
====================
|
||||||
|
Copyright
|
||||||
|
====================
|
||||||
|
|
||||||
|
| 书名《Python Cookbook》3rd Edition
|
||||||
|
| 作者 David Beazley, Brian K. Jones
|
||||||
|
| 版本 第三版
|
||||||
|
| 出版日期 2013年5月08日
|
||||||
|
| Copyright © 2013 David Beazley and Brian Jones. All rights reserved.
|
||||||
|
| 更多发布信息,请参考 http://oreilly.com/catalog/errata.csp?isbn=9781449340377
|
||||||
|
|
||||||
|
|
|
||||||
|
|
||||||
@@ -3,14 +3,18 @@
|
|||||||
You can adapt this file completely to your liking, but it should at least
|
You can adapt this file completely to your liking, but it should at least
|
||||||
contain the root `toctree` directive.
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
Welcome to python3-cookbook's documentation!
|
================================================
|
||||||
============================================
|
Python Cookbook 3rd Edition Documentation!
|
||||||
|
================================================
|
||||||
|
|
||||||
Contents:
|
Contents:
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
copyright
|
||||||
preface
|
preface
|
||||||
|
chapters/*
|
||||||
|
aboutme
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,55 @@
|
|||||||
前言
|
前言
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
关于本书
|
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
作者的话
|
||||||
|
----------------------------------
|
||||||
|
自从2008年以来,Python3横空出世并慢慢进化。Python3的流行一直被认为需要很长一段时间。事实上,到我写这本书的2013年,绝大部分的Python程序员仍然在生产环境中使用的是版本2系列,最主要是因为Python3不向后兼容。毫无疑问,对于工作在遗留代码上的每个程序员来讲,向后兼容是不得不考虑的问题。但是放眼未来,你就会发现Python3给你带来不一样的惊喜。
|
||||||
|
|
||||||
接触到《Python Cookbook 3rd Edition》这本书时,它还没有相应的中文版。在阅读这本书时,突然想到:为什么把它不翻译出来也方便别人阅读呢?于是决定在阅读时逐章地翻译这本书。这不是一项轻松的工作,却是一件值得做的工作:不仅方便了别人,而且对自己翻译能力也是一种锻炼和提升。
|
----------------------------------
|
||||||
|
这本书适合谁
|
||||||
|
----------------------------------
|
||||||
|
这本书的目标读者是那些想深入理解Python语言机制和最新编程技能的资深程序员。
|
||||||
|
|
||||||
本书在翻译时遵循一条原则,就是通过查阅《Python3.4.0用户手册》在完全读懂文字和代码后再翻译,而不是仅仅根据文字翻译,这样翻译和作者要表达的意思会更加接近并且更加容易理解。原书正文之前除了作者简介以外的那些对于阅读没多大帮助的信息留到最后一章翻译完成后再翻译补齐(如果能坚持翻译到那一章的话)。
|
这本书不适合Python的初学者。事实上,本书已经假定了读者已经有了一定的Python基础,看完过几本入门书籍。本书也不是那种快速参考手册(可以很快的查询某个模块下的某个函数)。本书旨在聚焦几个最重要的主题,演示几种可能的解决方案,作为一个跳板,你可以经此进入一些更高级的主题,这些可以在网上或者参考手册中找到。
|
||||||
|
|
||||||
目前翻译了第一章——数据结构与算法 ,感觉到如果对Python标准库一无所知,读起来不会很容易。所以建议您在阅读时,最好也了解一下手册中相关的地方。
|
----------------------------------
|
||||||
|
本书示例代码
|
||||||
|
----------------------------------
|
||||||
|
本书几乎所有源代码均可以在 http://github.com/dabeaz/python-cookbook 上面找到。作者欢迎各位修正bug,改进代码和评论。
|
||||||
|
|
||||||
译文中有什么错漏的地方请大家见谅,也欢迎大家指正:yidao620@gmail.com
|
本书就是帮助你完成你的工作。一般来讲,只要在本书上面的实例代码,你都可以随时拿过去在你的源码和文档中使用。你不需要向我们申请许可,除非你抄袭的太过分了。比如说复制几个代码片段去完成一个程序不需要许可,贩卖或者分发实例代码的光盘不需要许可。引用本书和实例代码去回答一个问题也需要许可。然后,合并大量的代码带你的正式产品文档中去是需要我们的许可的。
|
||||||
|
|
||||||
|
我们不会要求你添加代码的出处,包括标题,作者,出版社,ISBN。比如:Python Cookbook, 3rd edition, by David Beazley and Brian K. Jones (O’Reilly). Copyright 2013 David Beazley and Brian Jones, 978-1-449-34037-7. 但是如果你这么做了,我们会很感激的。
|
||||||
|
|
||||||
|
----------------------------------
|
||||||
|
联系我们
|
||||||
|
----------------------------------
|
||||||
|
请将关于本书的评论和问题发送给出版社:
|
||||||
|
|
||||||
|
| O’Reilly Media, Inc.
|
||||||
|
| 1005 Gravenstein Highway North
|
||||||
|
| Sebastopol, CA 95472
|
||||||
|
| 800-998-9938 (in the United States or Canada)
|
||||||
|
| 707-829-0515 (international or local)
|
||||||
|
| 707-829-0104 (fax)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
||||||
|
本书网站: http://oreil.ly/python_cookbook_3e ,上面有勘误表,示例和一些其他信息。
|
||||||
|
|
||||||
|
如果想要评论或者是问一下本书技术方面的问题, 请发送邮件至: bookquestions@oreilly.com
|
||||||
|
|
||||||
|
更多关于我们的书籍,讨论会,新闻, 请访问我们的网站: http://www.oreilly.com
|
||||||
|
|
||||||
|
在Facebook上查找我们: http://facebook.com/oreilly
|
||||||
|
|
||||||
|
在Twitter上关注我们: http://twitter.com/oreillymedia
|
||||||
|
|
||||||
|
在YouTube上观看我们: http://www.youtube.com/oreillymedia
|
||||||
|
|
||||||
|
----------------------------------
|
||||||
|
感谢
|
||||||
|
----------------------------------
|
||||||
|
我们由衷的感谢本书的技术审核者Jake Vanderplas, Robert Kern 和 Andrea Crotti的非常有有用的评论和建议,还有Python社区的帮助和鼓励。我们还想感谢上一个版本的编辑Jake Vanderplas, Robert Kern,and Andrea Crotti。尽管这个版本是最新的,但是前一个版本已经提供了一个感兴趣主题和解决方案的框架。最后,最最重要的就是,我们要感谢所有预览版本的读者,他们的评论和改进意见对本书很有帮助。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user