Windows下Python获取磁盘空闲空间并写入日志from ctypes import *import timeimport win32filerun = Truelogfile = open('.\\log.out','w+');#open log fileinput = raw_input(&q……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2154浏览 2513个赞
用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) 2821浏览 150个赞
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) 2895浏览 1153个赞
上线需要,将py的源码中注释删掉,然后编译成字节码。写此脚本主要是为了删除注释。当然如果上线不想放py源码,则在最后增加删除源码即可。#!/bin/env python# -*- coding:utf-8 -*-# -------------------------------# Filename: # Revision:# Date:……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2494浏览 1912个赞
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) 2759浏览 938个赞
python 类继承演示范例# a simple example of a class inheritance# tested with Python24 vegaseat 10aug2005help('object') # testclass Class1(object): ""&……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1487浏览 668个赞
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) 2597浏览 323个赞
python正则搜索范例,通过search正则搜索字符串# encoding: UTF-8 import re # 将正则表达式编译成Pattern对象 pattern = re.compile(r'world') # 使用search()查找匹配的子串,不存在能匹配的子串时将返回None # 这个例子中使用mat……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2382浏览 1699个赞
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) 2332浏览 335个赞
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) 3173浏览 1759个赞
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) 2981浏览 382个赞
从CVS库中迁出项目以后,在目录中含有CVS目录。通过python进行递归删除。由于PYTHON中貌似不能直接删除非空目录,所以先将CVS目录下的文件删除,再删除CVS目录。采用walk方法,递归遍历各目录。来源:http://blog.csdn.net/moxuansheng/article/details/6450687''……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1335浏览 657个赞
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) 2398浏览 868个赞
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) 2578浏览 1371个赞
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) 2298浏览 2404个赞
python 根据完整路径获得目录名,例如输入c:\\abc\\123.zip ,返回c:\\abcimport osos.path.dirname('c:\\abc\\123.zip') 返回结果:c:\\abc……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2813浏览 292个赞
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) 1506浏览 545个赞
模拟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) 1716浏览 746个赞
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) 1552浏览 609个赞
python adslimport osg_adsl_account = {"name": "adsl", "username": "0512...", "password": "..."} class Adsl……继续阅读 » 水墨上仙 5年前 (2021-01-15) 3081浏览 1273个赞
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) 3098浏览 1768个赞
通过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) 2837浏览 958个赞
Author:pakoEmail>alk:zealzpc@gmail.com对于服务器的监控来说,监控linux不管是自己动手写脚本还是用一些开源的工具比如nagios,zenoss什么的。但毕竟还是有些公司有windows做服务器的,相对linux来说,windows没有方便的shell,cmd下提供的命令对于监控来说远远没有linux方便……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2529浏览 1777个赞
……继续阅读 » 开心洋葱 5年前 (2021-01-15) 2785浏览 0评论438个赞
Centos7与Centos6.x有了很大的不同。为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。1、假定你的系统没有安装vnc的任何软件,那么,首先安装vnc1yum -y install tigervnc-server tigervnc2、Centos7之前的……继续阅读 » 开心洋葱 5年前 (2021-01-15) 3078浏览 0评论2555个赞
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) 1441浏览 0评论388个赞
JavaScript检测用户电脑是mac还是pcif (navigator.userAgent.indexOf('Mac OS X') != -1) { $("body").addClass("mac");} else { $("body").addClass(&……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2081浏览 571个赞
JavaScript判断Element是否支持 Attributefunction elementSupportsAttribute(element, attribute) { var test = document.createElement(element); if (attribute in test) { return true……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1966浏览 1631个赞
这段代码提供了两个方法对数组进行随机重排<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) 1842浏览 2164个赞
JavaScript控制元素的显示和隐藏<script type="text/javascript"><!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.di……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1761浏览 208个赞
这是一个JavaScript代码条使用的函数,在很多语言里都有类似的函数,用于输出所有的变量function var_dump( objElement, intLimit, intDepth ){ intDepth = intDepth?intDepth:0; intLimit = intLimit?intLimit:1; ……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1454浏览 1527个赞
JavaScript的大量字符串链接,如果直接使用加号链接,其实是非常消耗性能的,虽然现在的浏览器如firefox,chrome都会自动对其优化,但是我们在编程的时候还是尽量避免大量字符串直接用加号链接,尽量使用堆栈数组//直接使用加号链接字符串,慢var string = 'abc'; string += '……继续阅读 » 水墨上仙 5年前 (2021-01-15) 2754浏览 515个赞
JavaScript定义变量也和性能有关,看看下面的代码你就明白了,只是把变量声明换了个地方就可以让代码变快//未优化的代码,很慢for(var i = 0; i < 1000; i++){var my_variable = 'This is my variable';// Do something with my_va……继续阅读 » 水墨上仙 5年前 (2021-01-15) 1736浏览 1136个赞