python时间戳转换
升级某管理程序时使用,解决了时间计算方式不统一的问题
By admin|脚本编程|Be the first to comment!
升级某管理程序时使用,解决了时间计算方式不统一的问题
By admin|Linux系统|Be the first to comment!
_mysql.c: In function ‘_mysql_ResultObject_row_tell’:
_mysql.c:2082: error: ‘MYSQL_ROW_OFFSET’ undeclared (first use in this function)
_mysql.c:2082: error: expected ‘;’ before ‘r’
_mysql.c:2084: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
_mysql.c:2085: error: ‘_mysql_ResultObject’ has no member named ‘use’
_mysql.c:2090: error: ‘r’ undeclared (first use in this function)
(阅读全文……)
By admin|脚本编程|Be the first to comment!
我刚看python不超过10天,它难免会有BUG。不过在今后的学习当中将继续完善。预计在加入几个实用的功能并提供图形界面。
它能作什么?
读取用户指定的密码文件对邮箱(如yahoo)进行密码检索。
注意:这不是一个对指定用户名进行密码暴力猜解的程序。它通过已存在字典中的用户名和密码对邮箱进行检索。
成功率有多少?
这取决于字典好坏,有一部分人在网络上通通使用固定的密码和用户名
By admin|脚本编程|Be the first to comment!
测试方法:用python过滤出指定字符串,并和sed与grep执行时间对比
[root@jeantoe MyPy]# cat speed.py
import os, systestfile = open(‘/etc/passwd’)
for line in testfile:
if ‘root’ in line:
print line
[root@jeantoe MyPy]# time python speed.py
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
real 0m0.033s
user 0m0.024s
sys 0m0.009s
[root@jeantoe MyPy]# time grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
real 0m0.003s
user 0m0.000s
sys 0m0.003s
[root@jeantoe MyPy]# time sed -n ‘/root/p’ /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
real 0m0.003s
user 0m0.001s
sys 0m0.001s
By admin|脚本编程|3 Comments
If s and t are both strings, some Python implementations such as CPython can usually perform an in-place optimization for assignments of the form s = s + t or s += t. When applicable, this optimization makes quadratic run-time much less likely. This optimization is both version and implementation dependent. For performance sensitive code, it is preferable to use the str.join() method which assures consistent linear concatenation performance across versions and implementations.
文中的s和t是什么?
There are six sequence types: strings, Unicode strings, lists, tuples, buffers, and xrange objects.
For other containers see the built in dict and set classes, and the collections module.
代码片段。不言自明。
for root, dirs, files in os.walk('/media/cdrom0'): export+="\n %s;%s;%s" % (root,dirs,files) open('TokyoHot1', 'w').write(export)
for root, dirs, files in os.walk('/media/cdrom0'): export.append("\n %s;%s;%s" % (root,dirs,files)) open('TokyoHot2', 'w').write(''.join(export))