python基础篇是以Google for Education上面的 Google’s Python Class课程为主.这是一门非常适合初学者的课程.


Welcome to Google’s Python Class – this is a free class for people with a little bit of programming experience who want to learn Python. The class includes written materials, lecture videos, and lots of code exercises to practice Python coding. These materials are used within Google to introduce Python to people who have just a little programming experience. The first exercises work on basic Python concepts like strings and lists, building up to the later exercises which are full programs dealing with text files, processes, and http connections. The class is geared for people who have a little bit of programming experience in some language, enough to know what a “variable” or “if statement” is. Beyond that, you do not need to be an expert programmer to use this material.

To get started, the Python sections are linked at the left – Python Set Up to get Python installed on your machine, Python Introduction for an introduction to the language, and then Python Strings starts the coding material, leading to the first exercise. The end of each written section includes a link to the code exercise for that section’s material. The lecture videos parallel the written materials, introducing Python, then strings, then first exercises, and so on. At Google, all this material makes up an intensive 2-day class, so the videos are organized as the day-1 and day-2 sections.

This material was created by Nick Parlante working in the engEDU group at Google. Special thanks for the help from my Google colleagues John Cox, Steve Glassman, Piotr Kaminksi, and Antoine Picard. And finally thanks to Google and my director Maggie Johnson for the enlightened generosity to put these materials out on the internet for free under the under the Creative Commons Attribution 2.5 license – share and enjoy!



  1. 文档
  2. 视频
  3. 练习


就像刚刚学习c语言接触第一个"Hello world!“程序一样,下面就是一个简单的python版的"Hello world!“程序.

  • 代码示例

     3# 导入所用模块 -- sys 是常用的模块
     4import sys
     6# 代码写在main()里面
     7def main():
     8    print 'Hello World!'
     9    # 命令行的参数在 sys.argv[1], sys.argv[2] ...
    10    # sys.argv[0] 表示脚本名称
    12# 调用main()函数来启动程序的样板
    13if __name__ == '__main__':
    14    main()

    代码第一行#!/usr/bin/python是当使用./scrpt.py执行该段程序时指定解释器的路径. 显然这里是linux的路径,windows可以换成#!C:\Python2.7

< 前一篇 后一篇 >