05 2017 档案

摘要:1 #!/usr/bin/env python 2 # _*_ coding:UTF-8 _*_ 3 # __auth__: Dalhhin 4 # Python 3.5.2,Pycharm 2016.3.2 5 # 2017/05/15 6 7 import sys,os 8 9 def where(dbfile,where_list): #条件是一个... 阅读全文
posted @ 2017-05-19 21:43 SpeicalLife 阅读(542) 评论(0) 推荐(1)
摘要:#!/usr/bin/env python # _*_ coding:UTF-8 _*_ # __auth__:Dahlhin import sys userinfo = r'userinfo.txt' userlock = r'userlock.txt' def user_exist_check(user): '''检查用户是否存在''' with open(user... 阅读全文
posted @ 2017-05-10 19:40 SpeicalLife 阅读(354) 评论(0) 推荐(0)
摘要:1 #!/usr/bin/env python 2 # _*_ coding:UTF-8 _*_ 3 # 收集程序所占用的物理内存大小,占所有物理内存的比例 4 # OS: Centos 6.7 Python: 2.7.6 5 # __author__:Dahlhin 6 7 import sys 8 import os 9 from subprocess import ... 阅读全文
posted @ 2017-05-05 12:00 SpeicalLife 阅读(1351) 评论(0) 推荐(1)
摘要:1 #!/usr/bin/env python 2 3 import os 4 import string 5 6 #方法1:通过字符串的isdigits来判断 7 #filelist = os.listdir('/proc') 8 # 9 #for pid in filelist: 10 # if pid.isdigit(): 11 # print p... 阅读全文
posted @ 2017-05-04 21:09 SpeicalLife 阅读(674) 评论(0) 推荐(0)
摘要:1 #!/usr/bin/env python 2 #_*_ coding:utf-8 _*_ 3 #计算整个目录的大小,脚本接受-H参数,来加上适当的单位 4 #功能像du看齐 5 6 import os,sys 7 from optparse import OptionParser 8 9 10 def option(): 11 parser = Op... 阅读全文
posted @ 2017-05-03 15:42 SpeicalLife 阅读(460) 评论(0) 推荐(0)
摘要:生成器是一个可迭代的对象,可以对可迭代的对象进行便利,比如字符串、列表等,都是可迭代对象 def f(n): for i in range(n): yield i 特点: 1、当调用这个函数的时候,函数内部的代码并不立马执行,这个函数只是返回一个生成器对象 2、当使用for进行迭代的时候,函数内的代 阅读全文
posted @ 2017-05-02 23:04 SpeicalLife 阅读(583) 评论(0) 推荐(0)
摘要:hashlib用于对字符串或者文件进行加密。 使用方法1: hashlib.md5('str').hexdigest() 使用MD5对str进行加密,使用hexdigest(),16进制的方式打印 使用方法2: md5 = hashlib.md5() md5.update('hello') 如果第一 阅读全文
posted @ 2017-05-01 23:57 SpeicalLife 阅读(1230) 评论(0) 推荐(0)
摘要:Python 如何处理管道输入输出 sys.stdin 等于打开了一个文件对象,所有输入的文件都会写入到标准输入文件中(键盘) sys.stdout 等于打来了一个文件对象,使用.write()把信息写入到标准输出文件中(屏幕) 判断行数: 1 #!/usr/bin/env python 2 #_* 阅读全文
posted @ 2017-05-01 18:36 SpeicalLife 阅读(1383) 评论(0) 推荐(0)