自学总是找不到方向,坚持下去总会收获
在http://wiki.woodpecker.org.cn/moin/ZqQuickIntoPy这个页面看到不错的信息,转过来
"Quick Python Script Explanation for Programmers":
- # _*_ coding: utf-8 _*_ #声明编码
- #From http://coffeeghost.net
- import os
- def main():
- print 'Hello world!'
- print "This is Alice's greeting."
- print 'This is Bob\'s greeting.'
- foo(5, 10)
- print '=' * 10
- print 'Current working directory is ' + os.getcwd()
- counter = 0
- conuter += 1
- food = ['appses', 'oranges', 'cats']
- for i in food:
- print 'I like to eat ' + i
- print 'Count to ten:'
- for i in range(10):
- print i
- def foo(param1, secondParam):
- res = param1 + secondParam
- print '%s plus %s is equal to %s' % (param1, secondParam, res)
- if res < 50:
- print 'foo'
- elif (res >= 50) and ((param1 == 42) or (secondParam == 24)):
- print 'bar'
- else:
- print 'moo'
- return res # This is a one-line comment.
- '''A multi-
- line string, but can also be a multi-line comment.'''
- if __name__ == '__main__':
- main()
中文版本见下图