python正则表达式提取网页URLimport reimport urlliburl="http://www.itokit.com"s=urllib.urlopen(url).read()ss=s.replace(" ","")urls=re.findall(r"<……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2961浏览 400个赞
Windows下Python获取磁盘空闲空间并写入日志from ctypes import *import timeimport win32filerun = Truelogfile = open('.\\log.out','w+');#open log fileinput = raw_input(&q……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1791浏览 504个赞
用urllib按照百度音乐分类下载mp3。#!/usr/bin/env python#-*- coding: utf-8 -*-import urllibimport rebaseurl = "http://music.baidu.com"url = "http://music.baidu.com/search/……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1904浏览 999个赞
python处理大数字代码# check the numeric range of Python with huge factorials# factorial(69) still checks out accurately! Has 98 digits in it!# 171122452428141311372468338881272839092……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2515浏览 208个赞
上线需要,将py的源码中注释删掉,然后编译成字节码。写此脚本主要是为了删除注释。当然如果上线不想放py源码,则在最后增加删除源码即可。#!/bin/env python# -*- coding:utf-8 -*-# -------------------------------# Filename: # Revision:# Date:……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3476浏览 2245个赞
python提取页面内的url列表from bs4 import BeautifulSoupimport time,re,urllib2t=time.time()websiteurls={}def scanpage(url): websiteurl=url t=time.time() n=0 html=……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1561浏览 1810个赞
python 类继承演示范例# a simple example of a class inheritance# tested with Python24 vegaseat 10aug2005help('object') # testclass Class1(object): ""&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3359浏览 1377个赞
python统计文本字符串里面单词出现的频率# word frequency in a text# tested with Python24 vegaseat 25aug2005# Chinese wisdom ...str1 = """Man who run in front of car, get t……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1752浏览 587个赞
python正则搜索范例,通过search正则搜索字符串# encoding: UTF-8 import re # 将正则表达式编译成Pattern对象 pattern = re.compile(r'world') # 使用search()查找匹配的子串,不存在能匹配的子串时将返回None # 这个例子中使用mat……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2741浏览 245个赞
python 定时执行指定的函数# time a function using time.time() and the a @ function decorator# tested with Python24 vegaseat 21aug2005import timedef print_timing(func): def wr……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3402浏览 603个赞
python常用列表,数组操作范例# experimenting with Python's list# tested with Python23 vegaseat 21feb2005# import module os for method listdir()import os# creat an empty li……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3035浏览 964个赞
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……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1837浏览 2137个赞
从CVS库中迁出项目以后,在目录中含有CVS目录。通过python进行递归删除。由于PYTHON中貌似不能直接删除非空目录,所以先将CVS目录下的文件删除,再删除CVS目录。采用walk方法,递归遍历各目录。来源:http://blog.csdn.net/moxuansheng/article/details/6450687''……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2821浏览 2250个赞
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) ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1827浏览 149个赞
python 对元组对库存进行排序# sort an inventory list by item count# Python24 (needed) modified by vegaseat 10may2005import operator# create an inventory list of tuples# each tuple c……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1767浏览 781个赞
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……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2901浏览 2387个赞
python 根据完整路径获得目录名,例如输入c:\\abc\\123.zip ,返回c:\\abcimport osos.path.dirname('c:\\abc\\123.zip') 返回结果:c:\\abc……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2543浏览 2360个赞
python常用字典操作范例# experimenting with the Python dictionary# a seemingly unordered set of key:value pairs, types can be mixed# Python23 tested vegaseat 13feb2005# initia……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2638浏览 2549个赞
模拟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……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3016浏览 1910个赞
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……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2803浏览 2546个赞
python adslimport osg_adsl_account = {"name": "adsl", "username": "0512...", "password": "..."} class Adsl……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2215浏览 2813个赞
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 ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1926浏览 1506个赞
通过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……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2041浏览 2378个赞
Author:pakoEmail>alk:zealzpc@gmail.com对于服务器的监控来说,监控linux不管是自己动手写脚本还是用一些开源的工具比如nagios,zenoss什么的。但毕竟还是有些公司有windows做服务器的,相对linux来说,windows没有方便的shell,cmd下提供的命令对于监控来说远远没有linux方便……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2569浏览 2439个赞
……继续阅读 » 开心洋葱 6年前 (2021-01-15) 1887浏览 0评论1247个赞
Centos7与Centos6.x有了很大的不同。为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。1、假定你的系统没有安装vnc的任何软件,那么,首先安装vnc1yum -y install tigervnc-server tigervnc2、Centos7之前的……继续阅读 » 开心洋葱 6年前 (2021-01-15) 2688浏览 0评论2257个赞
1/Method Jblv\\Admin\\Grid::__toString() must not throw an exception, caught Error: Call to a member function newFromBuilder() on null2/……继续阅读 » 开心洋葱 6年前 (2021-01-15) 2824浏览 0评论1887个赞
JavaScript检测用户电脑是mac还是pcif (navigator.userAgent.indexOf('Mac OS X') != -1) { $("body").addClass("mac");} else { $("body").addClass(&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3452浏览 127个赞
JavaScript判断Element是否支持 Attributefunction elementSupportsAttribute(element, attribute) { var test = document.createElement(element); if (attribute in test) { return true……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2729浏览 1505个赞
这段代码提供了两个方法对数组进行随机重排<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……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2957浏览 2994个赞
JavaScript控制元素的显示和隐藏<script type="text/javascript"><!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.di……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2438浏览 738个赞
这是一个JavaScript代码条使用的函数,在很多语言里都有类似的函数,用于输出所有的变量function var_dump( objElement, intLimit, intDepth ){ intDepth = intDepth?intDepth:0; intLimit = intLimit?intLimit:1; ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2751浏览 1050个赞
JavaScript的大量字符串链接,如果直接使用加号链接,其实是非常消耗性能的,虽然现在的浏览器如firefox,chrome都会自动对其优化,但是我们在编程的时候还是尽量避免大量字符串直接用加号链接,尽量使用堆栈数组//直接使用加号链接字符串,慢var string = 'abc'; string += '……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3125浏览 1872个赞
JavaScript定义变量也和性能有关,看看下面的代码你就明白了,只是把变量声明换了个地方就可以让代码变快//未优化的代码,很慢for(var i = 0; i < 1000; i++){var my_variable = 'This is my variable';// Do something with my_va……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2846浏览 2972个赞
下面的代码通过Tkinter制作windows窗口界面,然后时间了一个简单的倒计时功能,代码可以直接运行# Countdown using Tkinter from Tkinter import *import timeimport tkMessageBoxclass App: def __init__(self,master……继续阅读 » 水墨上仙 6年前 (2021-01-13) 2833浏览 599个赞
python获得文件扩展名import os.path def file_extension(path): return os.path.splitext(path)[1] ……继续阅读 » 水墨上仙 6年前 (2021-01-13) 2967浏览 1282个赞
python通过win32com库播放mp3文件# Python supports COM, if you have the Win32 extensions# check your Python folder eg. D:\Python23\Lib\site-packages\win32com# also http://starship.pyt……继续阅读 » 水墨上仙 6年前 (2021-01-13) 1686浏览 2013个赞
python删除整个目录(目录非空),os.rmdir()只能删除空目录,下面的函数可以删除整个非空目录import osimport shutildef CleanDir( Dir ): if os.path.isdir( Dir ): paths = os.listdir( Dir ) for pa……继续阅读 » 水墨上仙 6年前 (2021-01-13) 1919浏览 1263个赞
python Image.blend ValueError: images do not matchfrom PIL import Image def blend_two_images(): img1 = Image.open( "bridge.png ") img1 = img1.convert(……继续阅读 » 开心洋葱 6年前 (2020-12-02) 3651浏览 5评论1256个赞
python 通关sleep函数等待到明天再执行def waitToTomorrow(): """Wait to tommorow 00:00 am""" tomorrow = datetime.datetime.replace(datetime.datetime.now……继续阅读 » 水墨上仙 6年前 (2020-11-25) 3360浏览 1668个赞
有些JS是可以后加载的,如果一直等待JS加载完成可能非常影响网页上的其它功能实现,比如计数器一类的,jQuery可以对JS进行动态加载。方法1:$.getscript("test.js");方法2:function loadjs(file){ var head = $('head').remo……继续阅读 » 水墨上仙 6年前 (2020-11-25) 2445浏览 212个赞
JavaScript随机打乱数组function Shuffle(o) { for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o;};使用方法var testArray = ……继续阅读 » 水墨上仙 6年前 (2020-11-18) 3044浏览 2382个赞
503 : HTTP Error 503……继续阅读 » 开心洋葱 6年前 (2020-11-17) 1817浏览 0评论2830个赞
### 首先登陆mysql shell$ mysql -u root -h 127.0.0.1 -p$密码输入### 查看mysql中现在执行的 所有线程mysql>show processlist; 线程id 登陆用户 主机 ……继续阅读 » 开心洋葱 6年前 (2020-11-16) 1699浏览 0评论2983个赞
Python遍历字符串中的每一个字符直接用for 语句#遍历字符串a = 'asd'for q in a: print(q)# 输出结果为asd ……继续阅读 » 水墨上仙 6年前 (2020-11-16) 2156浏览 1450个赞