这是本文档旧的修订版!
Python
从零开始
# ex1: Print # -*- coding: utf-8 -*- print "I'd much rather you 'not'." print 'I "said" do not touch this.' print "世界,你好" # on terminal, run ex1.py python ex1.py # ex2: Common # This is a common print "common" #This is a common too. # ex3: Numbers and Math # + - / * % < > <= >= # more: ** print "Result is ", 2*2-3/1, "+", 7%6,"=", 2, "is", 2>1, 2**8 # ex4: Variables And Names cars = 100 space_in_a_car = 4.0 # ex5: More Variables and Printing my_name = 'lucy' my_age = 16 print "My name is %s." % my_name print "My name is %s, i am %d old." % ( my_name, my_age ) # ex6: Strings and Text print "My name is: %r" % "lucy" # Print "My name is:'lucy'". print "My name is: '%s'" % "lucy" # Print the same. my_name = "My name is: %r" print my_name % 'lucy' # Print the same. # ex7: More Printing print "a" + "b" + "c" * 5 # Print "abccccc"
Tips
- 快速开一个静态http服务: 进入文件夹, 然后
python -m SimpleHTTPServer 80