摘要: 3.2 编程第一步当然,除了将两数简单相加,python可以完成很多复杂的工作。比如我们可以写出fibonacci序列。>>> # Fibonacci series:... # the sum of two elements defines the next... a, b = 0, 1>>> wh... 阅读全文
posted @ 2015-06-21 21:14 xiaolong92 阅读(360) 评论(0) 推荐(0)
摘要: 3.1.4.列表lists在python中有一些复合数据类型,通常用来使值分组在一起。最常用的是list列表,可以写成在方括号中用逗号分开的值或其他项。list可以包含不同类型的项目,但是通常大部分情况下所有的项目都是同类型的。>>> squares = [1, 4, 9, 16, 25]>>> s... 阅读全文
posted @ 2015-06-21 21:09 xiaolong92 阅读(128) 评论(0) 推荐(0)
摘要: 3.1.2.字符串python可以操作字符串,字符串包含在单引号或者双引号的内部,\可以用来转义引号escape quotes。 1 >>> 'spam eggs' # single quotes 2 'spam eggs' 3 >>> 'doesn\'t' # use \' to escape t... 阅读全文
posted @ 2015-06-21 21:04 xiaolong92 阅读(155) 评论(0) 推荐(0)
摘要: 3 . 注释 comments在python中以‘#’字符hash character开头,一直到这一行的结束。注释可以出现在一行的开始,或者在代码的后边空闲部分。但是不能出现在一个字面字符串string中。在字符串中,‘#’仅仅是一个‘#’字符。# this is the first commen... 阅读全文
posted @ 2015-06-20 23:09 xiaolong92 阅读(467) 评论(0) 推荐(0)