之前每次都是粗略的看看,现在开始决定,好好学习下python这个玩意。
会同步在此处更新学习笔记。
官方网站:
http://www.python.org/ 获取最新的代码、文档、新闻
An example:
kyle@ubuntu:~/workspace$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "Hello World"
Hello World
标示符:
命令俗成:
-
Class names start with anuppercaseletter and all other identifiers with a lowercase letter.
-
Starting an identifier with a single leading underscore(_) indicates by convention that the identifier is meant to beprivate.
-
Starting an identifier with two leading underscores indicates a strongly private identifier.
-
If the identifier also ends with two trailing underscores, the identifier is alanguage-defined special name.
and | exec | not |
assert | finally | or |
break | for | pass |
class | from | |
continue | global | raise |
def | if | return |
del | import | try |
elif | in | while |
else | is | with |
except | lambda | yield |
python里没有大括号,靠缩进。
Python has five standard data types:
-
Numbers: int / long / float / complex
-
String:
str = 'Hello World!'
-
List
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
-
-
Tuple:
-
Tuples can be thought of as read-only lists.
-
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
-
Dictionary