Code Like a Pythonista: Idiomatic Python
In this interactive tutorial, we'll cover many essential Python idioms and techniques in depth, adding immediately useful tools to your belt. There are 3 versions of this presentation: ©2006-2008, licensed under a Creative Commons Attribution/Share-Alike (BY-SA) license. My credentials: I am a resident of Montreal,father of two great kids, husband of one special woman,a full-time Python programmer,author of the Docutils project and reStructuredText,an editor of the Python Enhancement Proposals (or PEPs),an organizer of PyCon 2007, and chair of PyCon 2008,a member of the Python Software Foundation,a Director of the Foundation for the past year, and its Secretary. In the tutorial I presented at PyCon 2006 (called Text & Data Processing), I was surprised at the reaction to some techniques I used that I had thought were common knowledge. Many of you will have seen some of these techniques and idioms before. These are the guiding principles of Python, but are open to interpretation. import this
For Beginners
Welcome! Are you completely new to programming? If not then we presume you will be looking for information about why and how to get started with Python. Fortunately an experienced programmer in any programming language (whatever it may be) can pick up Python very quickly. It's also easy for beginners to use and learn, so jump in! Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. If you want to know whether a particular application, or a library with particular functionality, is available in Python there are a number of possible sources of information. If you have a question, it's a good idea to try the FAQ, which answers the most commonly asked questions about Python. If you want to help to develop Python, take a look at the developer area for further information.
使用python抓取网页(以人人网新鲜事和团购网信息为例)
前一段时间写的小东西,一直没工夫把他系统写出来,今天眼睛疼,就写写吧~~(原来博主不蛋疼时也会更新博客的哈~) python抓取网页基础 python自己带有很多网络应用相关的模块,如:ftplib用于FTP相关操作,smtplib和poplib用于收发电子邮件等等,利用这些 模块自己写一个FTP软件或是邮件客户端类软件完全是可能的,我就简单的试过完全用python脚本收发邮件和操作自己的FTP服务器。当然,这都不是今 天的主角,我们今天要用到的几个模块是:urllib,urllib2,cookielib,BeautifulSoup,我们先来简单介绍下。 urllib和urllib2自然都是处理URL相关的操作,urllib可以从指定的URL下载文件,或是对一些字符串进行编码解码以使他们成为特定的 URL串,而urllib2则比urllib更2一点,哦不对,是更牛逼一点。 我们先来看看最简单的网页抓取,其实网页抓取就是将所要的网页源代码文件下载下来,然后对其分析以提取对自己有用的信息。 import urllibhtml_src = urllib.urlopen(' 这样就会打印出百度首页的HTML源码了,还是很easy的。 from BeautifulSoup import BeautifulSoupparser = BeautifulSoup(html_src) 这样,后续处理HTML源码的工作交给parser变量来负责就好,我们可以简单的调用parser的prettify函数来相对美观的显示源码, 可以看到这样就能看到中文字符了,因为BeautifulSoup能自动处理字符问题,并将返回结果都转化为Unicode编码格式。 抓取人人网的新鲜事 前面讲的是最简单的抓取情形了,但通常我们需要面对更复杂的情形,拿人人网来说,需要登录自己的账号才能显示新鲜事,这样我们就只能求助于更2一点 的urllib2模块了。 首先import我们需要的所有模块,然后使用urllib2模块的HTTPCookieProcessor搭建一个处理cookie的 Handler,传入cookielib模块的CookieJar函数作为参数,这个这个函数处理HTTP的cookie,简单地说,它从HTTP请求中 提取cookie,然后将其返回给HTTP响应。
Eric Walstad's crew quarters on the Starship
Hello World! I'm busilly tuning the hyper drive right now. Please have a seat and enjoy my spartan quarters or have a look at my business site: or the Django Critter that helps me write code at the speed of light. links I've found useful over the years of Python programmingPythonDive Into PythonCode Like a Pythonista: Idiomatic PythonBitManipulation - PythonInfo WikiCharming Python: Using state machinesCSV module ExamplesDebugging python c extensionsEpydocGnuplot.pyPython bindings to the Xapian search enginePython SidebarPython Standard LoggingSending email with PythonSingleton Mixin - singletonmixin.py The Borg patternThe Epytext Markup LanguageUsing Mix-ins with Python | Linux JournalXapian: DocumentationLearning to programByte of Python:Main Page - Text
LIBSVM Tools
This page provides some miscellaneous tools based on LIBSVM (and LIBLINEAR). Roughly they include Disclaimer: We do not take any responsibility on damage or other problems caused by using these software and data sets. Please download the zip file. Please download the zip file. Please download the zip file. T. You can use either MATLAB or Python.
Python for Fun
This collection is a presentation of several small Python programs. They are aimed at intermediate programmers; people who have studied Python and are fairly comfortable with basic recursion and object oriented techniques. Each program is very short, never more than a couple of pages and accompanied with a write-up. I have found Python to be an excellent language to express algorithms clearly. From many years of programming these are some of my favorite programs. Many thanks to Paul Carduner and Jeff Elkner for their work on this page, especially for Paul's graphic of Psyltherin (apologies to Harry Potter) and to the teams behind reStructured text and Sphinx to which the web pages in this collection have been adapted. Chris Meyers
Bruce Eckel's MindView, Inc: Thinking in Python
You can download the current version of Thinking in Python here. This includes the BackTalk comment collection system that I built in Zope. The page describing this project is here. The current version of the book is 0.1. The source code is in the download package. This is not an introductory Python book. However, Learning Python is not exactly a beginning programmer's book, either (although it's possible if you're dedicated). Revision History Revision 0.1.2, December 31 2001.
How to Think Like a Computer Scientist
Learning with Python by Allen Downey, Jeff Elkner and Chris Meyers. This book is now available for sale at Lulu.com. Hardcopies are no longer available from Green Tea Press. How to Think... is an introduction to programming using Python, one of the best languages for beginners. How to Think... is a Free Book available under the GNU Free Documentation License. Please send suggestions, corrections and comments about the book to feedback{at}thinkpython{dot}com. Download The book is available in a variety of electronic formats: Precompiled copies of the book are available in PDF and Postscript . Translations Here are some translations of the book into other (natural) languages: Spanish translation by Gregorio Inda. Other Free Books by Allen Downey are available from Green Tea Press. If you are using this book and would like to make a contribution to support my work, please consider making a donation toward my web hosting bill by clicking on the icon below.
R by example
Basics Reading files Graphs Probability and statistics Regression Time-series analysis All these examples in one tarfile. Outright non-working code is unlikely, though occasionally my fingers fumble or code-rot occurs. Other useful materials Suggestions for learning R The R project is at : In particular, see the `other docs' there. Over and above the strong set of functions that you get in `off the shelf' R, there is a concept like CPAN (of the perl world) or CTAN (of the tex world), where there is a large, well-organised collection of 3rd party software, written by people all over the world. The dynamism of R and of the surrounding 3rd party packages has thrown up the need for a newsletter, R News. library(help=boot) library(boot) ? But you will learn a lot more by reading the article Resampling Methods in R: The boot package by Angelo J. Ajay Shah, 2005
Python Tutorials for Kids 8+