按类别查询搜索结果
关于关键词 的检测结果,共 879
xupengtao7 | 2014-03-03 17:24:11 | 阅读(2750) | 评论(2)
Python是一种解释型的面向对象的语言,优点比较突出,在python语言中,有一个标准模块叫OS模块,包含普遍的系统操作功能。这次就简单记录一些常用的linux与python.os的一些相关方法。1:查看当前所在目录Linux:pwdwKioL1MUDD2hCM0iAAA31sZI29Y578.jpgPython.os: os.getcwd()wKioL1MUDHuTSxMJAAAwcW91xHY280.jpg...【阅读全文】
huodiewj | 2014-02-28 17:06:00 | 阅读(3200) | 评论(0)
--------------------------------------------------------------------------#一个停止并等待输入或输出的程序成为被阻塞的程序#死锁问题,在每次发送数据时接收端都接受一次,避免数据积压--------------------------------------------------------------------------基本客户端操作---------------------------...【阅读全文】
【LINUX】 python中递归
悠悠_Mother | 2014-02-28 16:16:10 | 阅读(660) | 评论(0)
有用的递归函数包含以下几部分:1. 当函数直接返回值时有基本实例(最小可能性问题)2.递归实例,宝货一个或者多个问题最小部分的递归调用递归的经典:1. 阶乘 和幂的计算n!的计算:def factorial(n):    if n ==1:        return 1    esle: ...【阅读全文】
悠悠_Mother | 2014-02-28 16:01:11 | 阅读(330) | 评论(0)
1.如果想给函数写文档,让后面使用函数的人能理解的话,可以加一些注释(#开头)2. 在函数的开头写下字符串,会作为函数的一部分进行存储,称为文档字符串例如:def square(x):    'calculates the squareof the number x.'    return x*x文档字符串的访问方式:>>square.__doc__'calculate...【阅读全文】
【LINUX】 Python GIL
controltable | 2014-02-28 10:40:13 | 阅读(0) | 评论(0)
For more than a decade, no single issue has caused more frustration or curiosity for Python novices and experts alike than the Global Interpreter Lock.An Open QuestionEvery field has one. A problem that has been written off as too difficult, too time consuming. Merely mentioning an attempt...【阅读全文】
悠悠_Mother | 2014-02-27 11:08:26 | 阅读(3720) | 评论(0)
1. 在python文件里第一行加上#! /usr/bin/python,即你的python解释器所在的目录。2. 另外还有一种写法是#! /usr/bin/env python编辑完成python脚本文件后为它加上可执行权限。例如你的python脚本文件叫做runit.py,那么就在shell中输入如下命令:chmod +x runit.py之后直接在shell中输入./runit.py就可以执行你的python...【阅读全文】
hbhe0316 | 2014-02-22 23:46:54 | 阅读(3220) | 评论(0)
此脚本找到large_re_file.txt的行数以及pDq的行数。点击(此处)折叠或打开[root@oracle11g test]# cat re_loop_nocompile.py #!/usr/bin/env pythonimport redef run_re():    pattern =...【阅读全文】
【LINUX】 Python文本处理
hbhe0316 | 2014-02-22 22:06:25 | 阅读(1110) | 评论(0)
1.in 和 not in区别点击(此处)折叠或打开[root@oracle11g home]# ipython/usr/lib/python2.6/site-packages/IPython/Magic.py:38: DeprecationWarning: the sets module is deprecated  from sets import SetPython 2.6.6 (r266:84292, M...【阅读全文】
kouyanghao | 2014-02-21 20:32:58 | 阅读(1390) | 评论(0)
一、相关代码数据库配置类MongoDBConn.py12345678910...【阅读全文】
zcanoe | 2014-02-21 09:52:59 | 阅读(6010) | 评论(0)
今天遇到logging handler指向rsyslog出现多条日志之间没有换行符,最后发现在每条日志的最后带上一个空白符(空格、tab)问题就不会出现了。为此还看了看loging.handlers.SysLogHandler的实现,发现每条日志的最后都会加上\000。但是还是没有解析为什么出现上面的问题,看来这个需要看rsyslog的实现才行。...【阅读全文】
hbhe0316 | 2014-02-19 00:11:28 | 阅读(1070) | 评论(0)
[root@oracle11g home]# cat pysysinfo_func_2.py点击(此处)折叠或打开#!/usr/bin/env python#A System Information Gathering Scriptimport subprocess#Command 1def uname_func(): &nbs...【阅读全文】
【LINUX】 Python导入模块
hbhe0316 | 2014-02-19 00:04:07 | 阅读(650) | 评论(0)
这个很简单,只需要>>> import pysysinfoGathering system information with uname command:Linux oracle11g 2.6.32-279.el6.x86_64 #1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU/LinuxGathering diskspace information df command:文件系统      容量  已用  可用 ...【阅读全文】
【LINUX】 Python函数封装
hbhe0316 | 2014-02-18 23:56:24 | 阅读(1240) | 评论(0)
[root@oracle11g home]# cat pysysinfo_func.py #!/usr/bin/env python#A System Information Gathering Scriptimport subprocess#Command 1def uname_func():uname = "uname"uname_arg = "-a"print "Gathering system information with %s command:\n" %unamesubprocess.call([uname,uname_arg])#Com...【阅读全文】
hbhe0316 | 2014-02-18 23:43:49 | 阅读(1210) | 评论(0)
[root@oracle11g home]# cat pysysinfo.py #!/usr/bin/env python#A System Information Gathering Scriptimport subprocess#Command 1uname = "uname"uname_arg = "-a"print "Gathering system information with %s command:\n" %unamesubprocess.call([uname,uname_arg])#Command 2diskspace = "df"...【阅读全文】
hbhe0316 | 2014-02-18 23:35:20 | 阅读(1580) | 评论(0)
用Python语言封装了一个linux命令,代码如下:[root@oracle11g home]# cat pyls.py #!/usr/bin/env python#Python wrapper for the ls commandimport subprocesssubprocess.call(["ls","-l"])[root@oracle11g home]# ./pyls.py 总用量 12drwx------. 5 oracle oinstall 4096 2月  12 18:11 oracle...【阅读全文】
controltable | 2014-02-18 17:14:29 | 阅读(0) | 评论(0)
how to change the default python version?I'm wanting to use some newer software that requires Python 2.6, and we currently have both 2.4and 2.6 installed on our dedicated CentOS server, which looks like this:$ which python /usr/local/bin/python$ which python2.6 /usr/bin/python2.6 $ which ...【阅读全文】
cengku | 2014-02-18 14:28:33 | 阅读(21860) | 评论(0)
Python 命令行输出的颜色设置【阅读全文】
cengku | 2014-02-18 14:27:52 | 阅读(0) | 评论(0)
while 1:    try:        /* do something...*/        if 成功:            break    except:        cont...【阅读全文】
hbhe0316 | 2014-02-12 16:59:51 | 阅读(1110) | 评论(0)
1.从用户那里得到输入最容易的方法就是使用raw_input函数,[root@oracle11g ~]# pythonPython 2.6.6 (r266:84292, May  1 2012, 13:52:17) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> user = raw_input('Enter login nam...【阅读全文】
cengku | 2014-02-10 14:29:22 | 阅读(2080) | 评论(0)