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) 2151浏览 1526个赞
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) 1793浏览 437个赞
从CVS库中迁出项目以后,在目录中含有CVS目录。通过python进行递归删除。由于PYTHON中貌似不能直接删除非空目录,所以先将CVS目录下的文件删除,再删除CVS目录。采用walk方法,递归遍历各目录。来源:http://blog.csdn.net/moxuansheng/article/details/6450687''……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2113浏览 567个赞
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) 2774浏览 2026个赞
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) 1547浏览 2519个赞
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) 2282浏览 2123个赞
python 根据完整路径获得目录名,例如输入c:\\abc\\123.zip ,返回c:\\abcimport osos.path.dirname('c:\\abc\\123.zip') 返回结果:c:\\abc……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2508浏览 288个赞
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) 2074浏览 1392个赞
模拟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) 2750浏览 1703个赞
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) 1725浏览 2689个赞
python adslimport osg_adsl_account = {"name": "adsl", "username": "0512...", "password": "..."} class Adsl……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1939浏览 1586个赞
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) 1783浏览 1982个赞
通过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) 1961浏览 2574个赞
Author:pakoEmail>alk:zealzpc@gmail.com对于服务器的监控来说,监控linux不管是自己动手写脚本还是用一些开源的工具比如nagios,zenoss什么的。但毕竟还是有些公司有windows做服务器的,相对linux来说,windows没有方便的shell,cmd下提供的命令对于监控来说远远没有linux方便……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2829浏览 2044个赞
……继续阅读 » 开心洋葱 6年前 (2021-01-15) 2701浏览 0评论1727个赞
Centos7与Centos6.x有了很大的不同。为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。1、假定你的系统没有安装vnc的任何软件,那么,首先安装vnc1yum -y install tigervnc-server tigervnc2、Centos7之前的……继续阅读 » 开心洋葱 6年前 (2021-01-15) 2257浏览 0评论2551个赞
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) 2175浏览 0评论2243个赞
JavaScript检测用户电脑是mac还是pcif (navigator.userAgent.indexOf('Mac OS X') != -1) { $("body").addClass("mac");} else { $("body").addClass(&……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3478浏览 1450个赞
JavaScript判断Element是否支持 Attributefunction elementSupportsAttribute(element, attribute) { var test = document.createElement(element); if (attribute in test) { return true……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2165浏览 1146个赞
这段代码提供了两个方法对数组进行随机重排<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) 3455浏览 254个赞
JavaScript控制元素的显示和隐藏<script type="text/javascript"><!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.di……继续阅读 » 水墨上仙 6年前 (2021-01-15) 3183浏览 528个赞
这是一个JavaScript代码条使用的函数,在很多语言里都有类似的函数,用于输出所有的变量function var_dump( objElement, intLimit, intDepth ){ intDepth = intDepth?intDepth:0; intLimit = intLimit?intLimit:1; ……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1903浏览 1529个赞
JavaScript的大量字符串链接,如果直接使用加号链接,其实是非常消耗性能的,虽然现在的浏览器如firefox,chrome都会自动对其优化,但是我们在编程的时候还是尽量避免大量字符串直接用加号链接,尽量使用堆栈数组//直接使用加号链接字符串,慢var string = 'abc'; string += '……继续阅读 » 水墨上仙 6年前 (2021-01-15) 2617浏览 2053个赞
JavaScript定义变量也和性能有关,看看下面的代码你就明白了,只是把变量声明换了个地方就可以让代码变快//未优化的代码,很慢for(var i = 0; i < 1000; i++){var my_variable = 'This is my variable';// Do something with my_va……继续阅读 » 水墨上仙 6年前 (2021-01-15) 1928浏览 2206个赞
下面的代码通过Tkinter制作windows窗口界面,然后时间了一个简单的倒计时功能,代码可以直接运行# Countdown using Tkinter from Tkinter import *import timeimport tkMessageBoxclass App: def __init__(self,master……继续阅读 » 水墨上仙 6年前 (2021-01-13) 2445浏览 1550个赞
python获得文件扩展名import os.path def file_extension(path): return os.path.splitext(path)[1] ……继续阅读 » 水墨上仙 6年前 (2021-01-13) 4726浏览 1710个赞
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) 1657浏览 445个赞
python删除整个目录(目录非空),os.rmdir()只能删除空目录,下面的函数可以删除整个非空目录import osimport shutildef CleanDir( Dir ): if os.path.isdir( Dir ): paths = os.listdir( Dir ) for pa……继续阅读 » 水墨上仙 6年前 (2021-01-13) 1724浏览 720个赞
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) 3245浏览 5评论729个赞
python 通关sleep函数等待到明天再执行def waitToTomorrow(): """Wait to tommorow 00:00 am""" tomorrow = datetime.datetime.replace(datetime.datetime.now……继续阅读 » 水墨上仙 6年前 (2020-11-25) 3068浏览 1240个赞
有些JS是可以后加载的,如果一直等待JS加载完成可能非常影响网页上的其它功能实现,比如计数器一类的,jQuery可以对JS进行动态加载。方法1:$.getscript("test.js");方法2:function loadjs(file){ var head = $('head').remo……继续阅读 » 水墨上仙 6年前 (2020-11-25) 3584浏览 2503个赞
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) 1905浏览 2487个赞
503 : HTTP Error 503……继续阅读 » 开心洋葱 6年前 (2020-11-17) 2870浏览 0评论1089个赞
### 首先登陆mysql shell$ mysql -u root -h 127.0.0.1 -p$密码输入### 查看mysql中现在执行的 所有线程mysql>show processlist; 线程id 登陆用户 主机 ……继续阅读 » 开心洋葱 6年前 (2020-11-16) 3005浏览 0评论2858个赞
Python遍历字符串中的每一个字符直接用for 语句#遍历字符串a = 'asd'for q in a: print(q)# 输出结果为asd ……继续阅读 » 水墨上仙 6年前 (2020-11-16) 1970浏览 2067个赞
python旋转图片的代码# rotate an image counter-clockwise using the PIL image library# free from: http://www.pythonware.com/products/pil/index.htm# make sure to install PIL after your……继续阅读 » 水墨上仙 6年前 (2020-11-16) 2822浏览 2441个赞
python 计算字符串长度,一个中文算两个字符,先转换成utf8,然后通过计算utf8的长度和len函数取得的长度,进行对比即可知道字符串内中文字符的数量,自然就可以计算出字符串的长度了。来源:http://www.75271.comvalue=u'脚本12'length = len(value)utf8_length = ……继续阅读 » 水墨上仙 6年前 (2020-11-16) 2031浏览 1275个赞
python从网络端口读取文本数据# To test it with netcat, start the script and execute:# # echo "Hello, cat." | ncat.exe 127.0.0.1 12345#import socketHOST = 'localhos……继续阅读 » 水墨上仙 6年前 (2020-11-16) 2615浏览 189个赞
windows下通过批处理获得本机mac地址@ECHO OFF:: Check OS versionIF NOT "%OS%"=="Windows_NT" GOTO SyntaxSETLOCAL:: Check command line argumentsIF NOT "%~2"……继续阅读 » 水墨上仙 6年前 (2020-11-16) 3057浏览 2643个赞
转自:http://blog.csdn.net/marising/article/details/6551692在很久以前,我写了一个系列,Python和C和C++的交互,如下http://blog.csdn.net/marising/archive/2008/08/28/2845339.aspx目的是解决Python和C/C++的互操作性的问题,假如……继续阅读 » 水墨上仙 6年前 (2020-11-16) 1542浏览 2896个赞
回文,亦称回环,是正读反读都能读通的句子,亦有将文字排列成圆圈者,是一种修辞方式和文字游戏。下面的代码用于检测一个字符串是否是回文/**检测回文串: * 先判断该字符的第一个和最后一个字符是否相等。如果相等,检查第二个字符和倒数第二个字符 * 是否相等。这个过程继续进行,直到出现不配陪的情况或者字符串的所有字符都检验完了。当字 ……继续阅读 » 水墨上仙 6年前 (2020-11-16) 2752浏览 1356个赞
python显示生日是星期几# find the day of the week of a given date# Python will trap impossible dates like (1900, 2, 29)# tested with Python24 vegaseat 01aug2005from datetime i……继续阅读 » 水墨上仙 6年前 (2020-11-16) 1897浏览 823个赞
python比较两段文本的不同之处# find the difference between two texts# tested with Python24 vegaseat 6/2/2005import difflibtext1 = """The World's Shortest Books:……继续阅读 » 水墨上仙 6年前 (2020-11-16) 2792浏览 2980个赞
C++通过递归进行回文判断#include using namespace std; //将一整数逆序后放入一数组中(要求递归实现) int IsRound(char *str,int len) { if(*str==*(str+len-1)) return IsRound(str+1,len-2); if(le……继续阅读 » 水墨上仙 6年前 (2020-11-16) 3399浏览 2091个赞
python获取一组汉字拼音的首字母来源:http://wangwei007.blog.51cto.com/68019/983289作者:lover007#!/usr/bin/env python # -*- coding: utf-8 -*- def multi_get_letter(str_input): if ……继续阅读 » 水墨上仙 6年前 (2020-11-13) 2588浏览 2548个赞