02 2016 档案
Fedora 17配置ssh及Windows远程连接
摘要:转载自:http://nanjingjiangbiao-t.iteye.com/blog/1794213 Fedora 23 默认已经安装好openssh server了,不用再装不过默认情况下没有开启。 以下操作需要在root用户下进行。 1.检查是否已经正常安装 [root@localhost 阅读全文
posted @ 2016-02-11 22:17 o小小程序猿o 阅读(421) 评论(0) 推荐(0)
psycopg2接口的基本用法
摘要:转载自:http://zhiwei.li/text/2012/02/05/psycopg2接口的基本用法/ 与其他实现了DB API 2.0协议的其他数据库用户基本一致。 import psycopg2 ##连接到一个存在的数据库 conn = psycopg2.connect(“dbname=te 阅读全文
posted @ 2016-02-08 21:46 o小小程序猿o 阅读(9222) 评论(1) 推荐(0)
关于postgresql——常用操作指令
摘要:该文章转载自http://blog.chinaunix.net/uid-22920230-id-3493064.html 创建数据库 CREATE DATABASE test WITH OWNER = postgres ENCODING = 'UTF8'; 进入控制台方法,在postgreSQL的安 阅读全文
posted @ 2016-02-06 23:11 o小小程序猿o 阅读(701) 评论(0) 推荐(0)
编写带参数decorator
摘要:无参的@log装饰器: def log(f): def fn(x): print 'call ' + f.__name__ + '()...' return f(x) return fn 发现对于被装饰的函数,log打印的语句是不能变的(除了函数名)。 如果有的函数非常重要,希望打印出'[INFO] 阅读全文
posted @ 2016-02-05 10:41 o小小程序猿o 阅读(486) 评论(0) 推荐(0)
python自定义排序函数
摘要:Python内置的 sorted()函数可对list进行排序: >>>sorted([36, 5, 12, 9, 21]) [5, 9, 12, 21, 36] 但 sorted()也是一个高阶函数,它可以接收一个比较函数来实现自定义排序,比较函数的定义是,传入两个待比较的元素 x, y,如果 x 阅读全文
posted @ 2016-02-04 14:14 o小小程序猿o 阅读(780) 评论(0) 推荐(0)
python的filter()函数
摘要:filter()函数是 Python 内置的另一个有用的高阶函数。 filter()函数接收一个函数 f 和一个list,这个函数 f 的作用是对每个元素进行判断,返回 True或 False,filter()根据判断结果自动过滤掉不符合条件的元素,返回由符合条件元素组成的新list。 例如,要从一 阅读全文
posted @ 2016-02-03 17:49 o小小程序猿o 阅读(3045) 评论(0) 推荐(0)
python的reduce()函数
摘要:reduce()函数也是Python内置的一个高阶函数。 reduce()函数接收的参数和 map()类似,一个函数 f,一个list,但行为和 map()不同,reduce()传入的函数 f 必须接收两个参数,reduce()对list的每个元素反复调用函数f,并返回最终结果值。 例如,编写一个f 阅读全文
posted @ 2016-02-03 17:45 o小小程序猿o 阅读(72913) 评论(0) 推荐(8)
python的map()函数
摘要:map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回。 例如,对于list [1, 2, 3, 4, 5, 6, 7, 8, 9] 如果希望把list的每个元素都作平方,就可以用map( 阅读全文
posted @ 2016-02-03 17:42 o小小程序猿o 阅读(2238) 评论(0) 推荐(1)
Python主要模块和常用方法简览
摘要:原文地址:http://blog.csdn.net/hwhjava/article/details/22284399 PY核心模块方法1. os模块: os.remove() #删除文件 os.unlink() #删除文件 os.rename() #重命名文件 os.listdir() #列出指定目 阅读全文
posted @ 2016-02-03 15:59 o小小程序猿o 阅读(605) 评论(0) 推荐(0)
python之math模块
摘要:1.math简介 >>>import math #导入math模块 >>>dir(math) #这句可查看所有函数名列表 >>>help(math) #查看具体定义及函数原型 2.常用函数 acos(x) # Return the arc cosine (measured in radians) o 阅读全文
posted @ 2016-02-02 17:28 o小小程序猿o 阅读(716) 评论(0) 推荐(0)
python中的字符串和数字连接
摘要:1. 将数字强制转换成字符串 i = 1000 str1 = "hello" print str1 + str(i) 2. 格式化成字符串 i = 1000 str1 = "hello" print "%s %d" %(str1, i) 阅读全文
posted @ 2016-02-02 16:22 o小小程序猿o 阅读(3786) 评论(0) 推荐(0)
Python的maketrans() 方法
摘要:描述 Python maketrans() 方法用于创建字符映射的转换表,对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换的字符,第二个参数也是字符串表示转换的目标。 注:两个字符串的长度必须相同,为一一对应的关系。 语法 maketrans()方法语法: str.maketra 阅读全文
posted @ 2016-02-02 15:17 o小小程序猿o 阅读(785) 评论(0) 推荐(0)