
【Python】
CPP攻城师
You got a dream, you gotta protect it. People cant do something themselves,they wanna tell you you cant do it.If you want something, go get it.
展开
-
【Python】Python中基类函数的重载和基类函数的调用
刚接触Python语言的时间不长,对于这个语言的很多特性并不是很了解,有很多用法都是还不知道。今天想着写一个Python面向对象编程时的继承中的函数调用。分享出来,一起进步原创 2015-01-06 15:10:32 · 5528 阅读 · 0 评论 -
【Python】三元运算
Python中没有像C++和Java等语言中的三元运算符,但是可以用if else语句实现相同的功能:>>> condition = True>>> print 'True' if condition else 'False'True>>> condition = False>>> print 'True' if condition else 'False'False>>>原创 2014-12-04 19:45:36 · 1391 阅读 · 0 评论 -
【Python】Python中的True, False条件判断
对于有编程经验的程序员们都知道条件语句的写法:以C++为例:if (condition){ doSomething();}对于Python中的条件判断语句的写法则是下面的样子:if (condition): doSomething()那么对于条件语句中的condition什么时候为真什么时候为假呢?在C++/Java等高级语言中,如果条件的值为0或者引用的对原创 2014-12-04 19:46:15 · 36997 阅读 · 0 评论 -
【Python】Python一些特殊用法(map、reduce、filter、lambda、列表推导式等)
Map函数:原型:map(function, sequence),作用是将一个列表映射到另一个列表,使用方法:def f(x): return x**2l = range(1,10)map(f,l)Out[3]: [1, 4, 9, 16, 25, 36, 49, 64, 81]Reduce函数原型:reduce(function, sequence,转载 2015-02-04 08:54:46 · 2640 阅读 · 0 评论 -
【Python】urllib2访问url
今天刚写一个能访问web的python小程序,在网上搜了下,可以直接使用urllib2这个类库。通过访问远程的url就可以得到页面的全部html页面数据,当然也可以用来访问webservice,完成远程调用。代码很短,话不多说,直接上#encoding:utf-8import urllib2if __name__ == '__main__': url = 'http:原创 2015-02-26 21:21:06 · 2471 阅读 · 0 评论 -
centos7解决django.db.utils.OperationalError: FATAL: Peer authentication failed for user "postgres"
centos7下yum安装postgre数据库之后,数据库连接的配置位于/var/lib/pgsql/data/pg_hba.conf中。执行数据库迁移时报错信息如下。[root@localhost codeoncloud]# python manage.py migrateTraceback (most recent call last): File "manage.py", li原创 2015-07-01 12:02:23 · 6980 阅读 · 0 评论