python
文章平均质量分 67
北极蛤
这个作者很懒,什么都没留下…
展开
-
python小笔记
python支持编译和解释、面向对象、无须考虑内存管理,很强的可扩展性,可以把部分功能用C或C++实现,免费、开源。很强的可移植性和丰富类库。 第一个python脚本 [root@hc8 python]# cat helloworld.py print 'hello world' [root@hc8 python]# python helloworld.py hello world第一个交原创 2014-01-24 16:23:46 · 438 阅读 · 0 评论 -
python数据类型
python的数据类型: 数字、字符串、列表、元祖、字典 查看类型可以使用type函数如 type("abc") 数字: 整型、长整型、浮点型、复数 字符串: 单引号、双引号、3引号 >>> a='''abcde''' >>> a[1] 'b' >>> a[2:3] 'c' >>> a[2:4] 'cd' >>> a[2:] 'cde'原创 2014-01-25 14:19:00 · 431 阅读 · 0 评论 -
python流程控制结构
流程控制结构 选择: 判断表达式是否成立,非空、非0都是假,也可以直接利用布尔值True或False,相关运算符包括and or not [root@hc8 python]# cat iftest.py #!/usr/bin/python score1 = int(raw_input("input score1 :")) score2 = int(raw_input(原创 2014-01-26 11:35:43 · 680 阅读 · 0 评论 -
python自定义函数
[root@hc8 python]# cat funtest.py #!/usr/bin/python def fun(x): print "the number is:"+x def eq(x,y): if x == y: print x,"=",y def eq2(x,y=2): if x == y: print x,"=",y def原创 2014-02-07 14:57:27 · 613 阅读 · 0 评论 -
python面向对象1
#!/usr/bin/python class Person: name = "no name" age = -1 __color="yellow" def speak(self): print "I am "+self.name def run(self1): print self1.name+" is running" def getColor(self): p原创 2014-02-11 11:13:48 · 467 阅读 · 0 评论 -
python内部类
#!/usr/bin/python class outerclass: msg = "I am outer class" class interclass: msg = "I am inter class" o1 = outerclass() print o1.msg i1 = o1.interclass() print i1.msg i2 = ou原创 2014-02-13 10:30:20 · 4776 阅读 · 0 评论 -
python构造与析构
#!/usr/bin/python class Test: name = "" ## like toString in Java def __str__(self): return "class Test..." ##constructor def __init__(self,name='xxx'): self.name = name ##destructor def原创 2014-02-13 11:14:38 · 645 阅读 · 0 评论 -
Protocol Buffers 使用
PB是一个序列化的框架,相比其他框架来说,他更轻巧、简便,利用PB自身的语法可以快速的建立我们自己的数据结构,并且将其序列化,关于PB的语法可以参考: http://shitouer.cn/2013/04/protocol-buffers-language-guide/ 下面我们介绍他的基本使用 1、安装PB 可以到 http://code.google.com/p/protobu原创 2014-02-20 14:20:52 · 467 阅读 · 0 评论