如果当前日期是星期五下面的代码返回“Have a nice weekend!”,否则返回 “Have a nice day!”<html><body><?php$d=date("D");if ($d=="Fri") echo "Have……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2949浏览 905个赞
做站点时,通常要将图片缩小成合适的尺寸,jpg图片缩小比较容易,png图片如果带了透明色的话,按照jpg的方式来缩小的话,就会造成透明色损失。那么如何处理,才能保存透明色呢?主要是利用gd库的两个方法:imagecolorallocatealpha 分配颜色 + alphaimagesavealpha 设置在保存 png 图像时保存完整的 alpha ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1310浏览 2929个赞
php从数组中随机选择若干唯一元素<?php /* * $array = the array to be filtered * $total = the maximum number of items to return * $unique = whether or not to remove duplicates before g……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1623浏览 648个赞
下面的php代码用于测试给定密码的强度,最高强度为100<?php /** * * @param String $string * @return float * * Returns a float between 0 and 100. The closer the number is to 100 the * th……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1731浏览 441个赞
php单件模式实现代码演示<?php/** * @link https://github.com/MaGuowei * @copyright 2013 maguowei.com * @author Ma Guowei <imaguowei@gmail.com> */ /** * 单例模式 * Class Single……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1273浏览 1909个赞
通过下面的jQuery插件,你可以将图片放在一个数组里,然后告诉jQuery图片需要在什么地方背景轮换/*** jQuery Fading background roator** Copyright (c) 2012 Ryan Naddy (ryannaddy.com)* Dual licensed under the MIT and GPL ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1642浏览 2557个赞
php检测apache mod_rewrite模块是否安装/** * @title Check if Apache's mod_rewrite is installed. * * @author Pierre-Henry Soria <ph7software@gmail.com>……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2382浏览 344个赞
下面的jQuery插件允许你通过鼠标右键点击拖动overflow的元素,这个插件可以在移动设备上运行/*** jQuery Drag and Scroll** Copyright (c) 2012 Ryan Naddy (ryannaddy.com)* Dual licensed under the MIT and GPL licenses:……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1858浏览 922个赞
php利用反射实现插件机制的代码<?php /** * @name PHP反射API--利用反射技术实现的插件系统架构 * @author :PHPCQ.COM */ interface Iplugin{ public static function getName(); } funct……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1557浏览 1930个赞
下面的php代码可以对电子邮件地址进行简单验证和强验证,简单验证验证邮件格式和主机是否存在,强验证会连接邮件服务器进行验证,需要比较长时间<?php /* * __construct($email) takes an email address to check * * simpleCheck() ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2918浏览 1541个赞
一个自定义的php分页类代码<?phpclass Pagination{ // Default values var $items = -1; var $limit = NULL; var $target = ""; var $page = 1; var $adjacents = 1; var $showC……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2996浏览 2332个赞
PHP定时执行任务的实现ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去$interval=60*30;// 每隔半小时运行do{ //这里是你要执行的……继续阅读 » 水墨上仙 4年前 (2021-03-10) 3006浏览 819个赞
这段代码可以用来转换常规时间格式为unix时间戳,也可以将unix时间戳转换回来,例如:1332888820 格式转换成 2012-03-28 06:53:40的形式# -*- coding: utf-8 -*- import time def timestamp_datetime(value): format = '%Y-……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2660浏览 1955个赞
This is a simple function that runs another function in a different process by forking a new process which runs the function and waiting for the result in the parent. This can be u……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1444浏览 1312个赞
Python通过win32api递归遍历目录删除指定文件import win32conimport win32apiimport osdef del_dir(self,path): for file in os.listdir(path): file_or_dir = os.path.join(path,file) if os.pat……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2528浏览 1451个赞
python从url中获取文件名import urllib2 file_name = urllib2.unquote(url).decode('utf8').split('/')[-1]……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2696浏览 2711个赞
python中带有zlib库可以用来对数据进行压缩和解压缩,针对大量数据可以节省不少的空间import zlibdata='hello world'data = zlib.compress(data)#压缩#data此时的值为:'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2756浏览 428个赞
python将文本转换成图片输出#-*- coding:utf-8 -*- from PIL import Image,ImageFont,ImageDraw text = u'欢迎访问脚本分享网,http://www.75271.com' font = ImageFont.truetype("msyh……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1508浏览 986个赞
python通过wxPython打开并播放wav文件''' wx_lib_filebrowsebutton_sound.pyselect a sound file and play itwx.lib.filebrowsebutton.FileBrowseButton(parent, labelText, fileMas……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1958浏览 1936个赞
python3 短网址和数字的相互转换import mathimport decimal def convert_to_code(num): """ 将数字转换为代码 """ def get_num(num, out=''): ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1843浏览 1754个赞
python输出当前目录下的index.html文件路径import osimport sys path = os.path.join(os.path.dirname(sys.argv[0]), 'index.html')print path……继续阅读 » 水墨上仙 4年前 (2021-03-10) 3161浏览 388个赞
python删除列表中的重复记录def removeListDuplicates(seq): seen = set() seen_add = seen.add return [ x for x in seq if x not in seen and not seen_add(x) ]……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2366浏览 1147个赞
下面的代码通过自定义一个继承自threading.Thread的类来实现多线程编程,调用非常简单import threading import time class timer(threading.Thread): #The timer class is derived from the class threading.Thread ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1701浏览 1661个赞
python通过urllib2发送带cookie的求情import urllib2opener = urllib2.build_opener()opener.addheaders.append(('Cookie', 'cookiename=cookievalue'))f = opener.open(&quo……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1420浏览 738个赞
这里实现的是针对网关的欺骗。假如说,你要攻击A机器,其IP是192.168.1.100,MAC是aa:bb:cc:dd:ee:ff,这样你就可以发给网关一个伪造包,包的源IP为192.168.1.100,源MAC为00:11:22:33:44:55,这样就实现对了网关的欺骗。转自:http://www.cnblogs.com/lovedboy/#co……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2196浏览 1004个赞
python在windows下操作word的方法import win32comfrom win32com.client import Dispatch, constantsw = win32com.client.Dispatch('Word.Application')# 或者使用下面的方法,使用启动独立的进程:# w = ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2644浏览 1020个赞
python arp欺骗伪造网关代码转自:http://www.cnblogs.com/lovedboy/#coding:utf-8'''arp欺骗局域网pc,将伪造的网关mac以网关的arp应答发送给pc'''from scapy.all import ARP,send,arpin……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2996浏览 486个赞
python通过win32com打开word,excel,ppt,并控制其最大化、最小化显示import win32com.clientw=win32com.client.Dispatch("Word.Application")w.Visible=True #控制word显示w.WindowState = 1 #1表示正常,2……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2321浏览 1792个赞
如果一个函数中所有递归形式的调用都出现在函数的末尾,我们称这个递归函数是尾递归的。当递归调用是整个函数体中最后执行的语句且它的返回值不属于表达式的一部分时,这个递归调用就是尾递归。尾递归函数的特点是在回归过程中不用做任何操作,这个特性很重要,因为大多数现代的编译器会利用这种特点自动生成优化的代码。原理当编译器检测到一个函数调用是尾递归的时候,它就覆盖当前……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2660浏览 2606个赞
python从网络下载文件并获得文件大小、文件类型import urllib2from settings import COOKIES opener = urllib2.build_opener() cookies = ";".join("%s=%s" % (k, v) for k, v in COO……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2400浏览 502个赞
python里用java的模块SmartXLS和jpype修改excel文件# -*- coding: utf8 -*-"""使用java的模块SmartXLS[http://www.smartxls.com/indexj.htm]和jpype修改excel和xlrd,xlwt不同的是它可以生成和保持图表"……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2385浏览 1444个赞
python Web 框架bottle超清晰使用范例,通过这个范例你可以大概了解bottle是如何使用的#coding: utf-8from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template@r……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1909浏览 1095个赞
linux下通过python获得指定网卡的ip地址import socketimport fcntlimport struct def get_ip_address(ifname): """ >>> get_ip_address('lo') '1……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2320浏览 1840个赞
python将pvr格式转换成pvr.cczimport zlibimport structimport syspvr = sys.argv[1]ccz = pvr + ".ccz"pvr = open(pvr).read()ccz = open(ccz, "wb")ccz.write(str……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2424浏览 1799个赞
从脚本里运行scrapy的代码# This snippet can be used to run scrapy spiders independent of scrapyd or the scrapy command line tool and use it from a script. # # The multiprocessing librar……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1731浏览 1466个赞
python通过google api抓取google搜索结果,其中q参数为要搜索的关键词#!/usr/bin/python import urllib import simplejson query = urllib.urlencode({'q' : '75271.com'}) ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 3020浏览 818个赞
python通过mmap库映射文件到内存用法详解转自:http://blog.chinaunix.net/uid-20393955-id-1645587.html         &……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2209浏览 911个赞
python编写的两个简单的文本类游戏############################################################# - My version on the game "Dragon Realm".# - taken from the book "invent with py……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1998浏览 1723个赞
python通过程序向ppt文件里面插入新的幻灯片页面# -*- coding: UTF-8 -*-import win32com.clientimport win32com.client.dynamicimport os #我的範本(Template)檔名為 BugCurve.pptxdef PowerPoint(): ppt =……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2585浏览 2930个赞
python通过fileinput模块逐行读取文件#------------------------------------------------------------------------------# Name: read_lines.py# Author: Kevin Harris# Last M……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1830浏览 351个赞
python控制随机间隔一段时间发送邮件、消息或弹出窗口""" If you need to do something irregularly, randomly during the weekday, youoften forget. This script gives you mail, sms or popup w……继续阅读 » 水墨上仙 4年前 (2021-03-10) 3189浏览 2956个赞
python scrapy 网络采集使用代理的方法 1.在Scrapy工程下新建“middlewares.py”# Importing base64 library because we'll need it ONLY in case if the proxy we ……继续阅读 » 水墨上仙 4年前 (2021-03-10) 1364浏览 123个赞
时间限制:1000 ms | 内存限制:65535 KB输入两个整数a,b (0……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2866浏览 134个赞
python中使用反射的方法import sys, types,newdef _get_mod(modulePath): try: aMod = sys.modules[modulePath] if not isinstance(aMod, types.ModuleType): ra……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2473浏览 1790个赞
下面的代码依赖于winows com,所以必须在机器上安装PowerPoint才能用,可以将PPT文件中的所有纯文本信息进行输出到指定的文件,非常实用。import win32comfrom win32com.client import Dispatch, constantsppt = win32com.client.Dispatch('……继续阅读 » 水墨上仙 4年前 (2021-03-10) 2779浏览 1450个赞