Windows下Python获取磁盘空闲空间并写入日志from ctypes import *import timeimport win32filerun = Truelogfile = open('.\\log.out','w+');#open log fileinput = raw_input(&q……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2525浏览 1448个赞
用urllib按照百度音乐分类下载mp3。#!/usr/bin/env python#-*- coding: utf-8 -*-import urllibimport rebaseurl = "http://music.baidu.com"url = "http://music.baidu.com/search/……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2741浏览 1086个赞
python处理大数字代码# check the numeric range of Python with huge factorials# factorial(69) still checks out accurately! Has 98 digits in it!# 171122452428141311372468338881272839092……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2098浏览 2901个赞
上线需要,将py的源码中注释删掉,然后编译成字节码。写此脚本主要是为了删除注释。当然如果上线不想放py源码,则在最后增加删除源码即可。#!/bin/env python# -*- coding:utf-8 -*-# -------------------------------# Filename: # Revision:# Date:……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1502浏览 2405个赞
python提取页面内的url列表from bs4 import BeautifulSoupimport time,re,urllib2t=time.time()websiteurls={}def scanpage(url): websiteurl=url t=time.time() n=0 html=……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2734浏览 2146个赞
python 类继承演示范例# a simple example of a class inheritance# tested with Python24 vegaseat 10aug2005help('object') # testclass Class1(object): ""&……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2636浏览 1496个赞
python统计文本字符串里面单词出现的频率# word frequency in a text# tested with Python24 vegaseat 25aug2005# Chinese wisdom ...str1 = """Man who run in front of car, get t……继续阅读 » 水墨上仙 5年前 (2021-01-15) 3111浏览 2357个赞
python正则搜索范例,通过search正则搜索字符串# encoding: UTF-8 import re # 将正则表达式编译成Pattern对象 pattern = re.compile(r'world') # 使用search()查找匹配的子串,不存在能匹配的子串时将返回None # 这个例子中使用mat……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1945浏览 1614个赞
python 定时执行指定的函数# time a function using time.time() and the a @ function decorator# tested with Python24 vegaseat 21aug2005import timedef print_timing(func): def wr……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2408浏览 2874个赞
python常用列表,数组操作范例# experimenting with Python's list# tested with Python23 vegaseat 21feb2005# import module os for method listdir()import os# creat an empty li……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1728浏览 1669个赞
wxpython开发的简单的gui计算器# wxCalc1 a simple GUI calculator using wxPython# created with the Boa Constructor which generates all the GUI components# all I had to do is add some code……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1383浏览 2426个赞
从CVS库中迁出项目以后,在目录中含有CVS目录。通过python进行递归删除。由于PYTHON中貌似不能直接删除非空目录,所以先将CVS目录下的文件删除,再删除CVS目录。采用walk方法,递归遍历各目录。来源:http://blog.csdn.net/moxuansheng/article/details/6450687''……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1543浏览 554个赞
python删除过期文件代码片段# remove all jpeg image files of an expired modification date = mtime# you could also use creation date (ctime) or last access date (atime)# os.stat(filename) ……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1778浏览 2779个赞
python 对元组对库存进行排序# sort an inventory list by item count# Python24 (needed) modified by vegaseat 10may2005import operator# create an inventory list of tuples# each tuple c……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2407浏览 108个赞
wxPython listbox 使用演示# load a listbox with names, select a name and display in title# experiments with wxPython by vegaseat 20mar2005# Python v2.4 and wxPython v2.5# If yo……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2589浏览 2527个赞
python 根据完整路径获得目录名,例如输入c:\\abc\\123.zip ,返回c:\\abcimport osos.path.dirname('c:\\abc\\123.zip') 返回结果:c:\\abc……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2857浏览 2950个赞
python常用字典操作范例# experimenting with the Python dictionary# a seemingly unordered set of key:value pairs, types can be mixed# Python23 tested vegaseat 13feb2005# initia……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1873浏览 888个赞
模拟C和Pascal的结构体实现的Employee类,可以从cvs文件读取信息并搜索'''Class_StructEmp2_file.pymimic a C Structure or Pascal Record using a classload the data from a csv type file like t……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1383浏览 833个赞
python 一句话代码将图片变亮或者变暗# do pixel math on an image using the PIL image library# free from: http://www.pythonware.com/products/pil/index.htm# Python23 tested vegaseat 2……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1647浏览 2313个赞
python adslimport osg_adsl_account = {"name": "adsl", "username": "0512...", "password": "..."} class Adsl……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1932浏览 1648个赞
python播放wav音频文件# play a wave sound on a Windows Box# Python23 tested vegaseat 2/8/2005import winsoundimport time# pick a wave file supplied by Windows XP or one of your ……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2361浏览 1681个赞
通过wxpython编写windows GUI程序这段代码只是一个最简单的范例# using a wx.Frame, wx.MenuBar, wx.Menu, wx.Panel, wx.StaticText, wx.Button, # and a wx.BoxSizer to show a rudimentary wxPython Windows G……继续阅读 » 水墨上仙 5年前 (2021-01-15) 3076浏览 2009个赞
Author:pakoEmail>alk:zealzpc@gmail.com对于服务器的监控来说,监控linux不管是自己动手写脚本还是用一些开源的工具比如nagios,zenoss什么的。但毕竟还是有些公司有windows做服务器的,相对linux来说,windows没有方便的shell,cmd下提供的命令对于监控来说远远没有linux方便……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2603浏览 2359个赞
……继续阅读 » 开心洋葱 5年前 (2021-01-15) 1862浏览 0评论166个赞
Centos7与Centos6.x有了很大的不同。为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。1、假定你的系统没有安装vnc的任何软件,那么,首先安装vnc1yum -y install tigervnc-server tigervnc2、Centos7之前的……继续阅读 » 开心洋葱 5年前 (2021-01-15) 2384浏览 0评论2968个赞
1/Method Jblv\\Admin\\Grid::__toString() must not throw an exception, caught Error: Call to a member function newFromBuilder() on null2/……继续阅读 » 开心洋葱 5年前 (2021-01-15) 2918浏览 0评论480个赞
JavaScript检测用户电脑是mac还是pcif (navigator.userAgent.indexOf('Mac OS X') != -1) { $("body").addClass("mac");} else { $("body").addClass(&……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2043浏览 1242个赞
JavaScript判断Element是否支持 Attributefunction elementSupportsAttribute(element, attribute) { var test = document.createElement(element); if (attribute in test) { return true……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1853浏览 989个赞
这段代码提供了两个方法对数组进行随机重排<script>var count = 100000,arr = [];for(var i=0;i<count;i++){ arr.push(i);}//常规方法,sort()var t = new Date().getTime();Array.prototype.sort.cal……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1483浏览 514个赞
JavaScript控制元素的显示和隐藏<script type="text/javascript"><!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.di……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2377浏览 2140个赞
这是一个JavaScript代码条使用的函数,在很多语言里都有类似的函数,用于输出所有的变量function var_dump( objElement, intLimit, intDepth ){ intDepth = intDepth?intDepth:0; intLimit = intLimit?intLimit:1; ……继续阅读 » 水墨上仙 5年前 (2021-01-15) 3196浏览 384个赞
JavaScript的大量字符串链接,如果直接使用加号链接,其实是非常消耗性能的,虽然现在的浏览器如firefox,chrome都会自动对其优化,但是我们在编程的时候还是尽量避免大量字符串直接用加号链接,尽量使用堆栈数组//直接使用加号链接字符串,慢var string = 'abc'; string += '……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1476浏览 1767个赞
JavaScript定义变量也和性能有关,看看下面的代码你就明白了,只是把变量声明换了个地方就可以让代码变快//未优化的代码,很慢for(var i = 0; i < 1000; i++){var my_variable = 'This is my variable';// Do something with my_va……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2252浏览 1971个赞