摘要:由于pubwin自带的异地备份一直不好用,并且pubwin自带的37分钟备份也不方便手动备份,考虑用python 与写一个基于酷盘的pubwin数据备份工具(本来想基于百度云的,发现百度云用的人太多,并且百度默认给我空间比酷盘小),刚学python用来练手,蛮好的程序基于pc端,也就是说一般是需要在...
阅读全文
摘要:一个pymssql 的程序在解释器上运行正常,但是用py2exe打包后,提示ImportError: No module named _mssql百度了半天无果,然后bing,结果bing还是比百度靠谱,某神网的这段话,让我有了灵感,英语真心不怎么好滴说:FYI there is a separate newsgroup for py2exe atgmane.comp.python.py2exe. You may want to postthere also.Just as a suggestion, put an import decimal atthe top of your progra
阅读全文
摘要:随便拉了个学习时用的测试程序来做的实例,原程序如下:#Filename:for.pycount=0for i in range(1,100,2): count+=ielse: print 'that\'s over'print countraw_input("input Enter to quit:")下面是给程序写的py2exe脚本:#name:mysetup.pyfrom distutils.core import setupimport py2exesetup(version='1.0',description='for
阅读全文
摘要:python DB-API 连接mysql 要用到库pymssql 下载请到https://pypi.python.org/pypi/pymssql/2.0.1我这里下载的是ms windows installer版本exe文件,直接运行就可以了,whl和egg格式的看不懂怎么安装.下载完,试着连接到本机的pubwin数据库写了一句查询,很方便的样子 1 # -*- coding:gbk -*- 2 import pymssql 3 try: 4 con=pymssql.connect(host='.',user='sa',password='sa
阅读全文
摘要:先写上代码,有代码才好理解:#filename:classdemo.pyclass test: '''just person''' a=1 b=2 c=0 def __init__(self): '''just person's init''' test.c=test.c+1 def aadnb(self): return self.a+self.b def __del__(self): test.c=test.c-1 p=test()print test.cp.a=5p.b=7p1=tes
阅读全文
摘要:主要是通过os.popen读取命令输出实现的,os.popen启动新的进程,且将外部命令的输出作为文件类型对象返回。不能获得外部命令的返回值。既然是文件对象就可以直接用for in 来读取,代码如下:#!/usr/bin/python#fileName:getinfoinsh.py#get cpu,meminfo from top command.import osimport timedef getinfointop(): topp=os.popen("top -n1|grep -E '^Cpu|^Mem'") toppstr=topp.read() re
阅读全文