JavaScript判断Element是否支持 Attributefunction elementSupportsAttribute(element, attribute) { var test = document.createElement(element); if (attribute in test) { return true……继续阅读 » 水墨上仙 4年前 (2021-01-15) 2545浏览 225个赞
这段代码提供了两个方法对数组进行随机重排<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……继续阅读 » 水墨上仙 4年前 (2021-01-15) 1591浏览 1547个赞
JavaScript控制元素的显示和隐藏<script type="text/javascript"><!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.di……继续阅读 » 水墨上仙 4年前 (2021-01-15) 1971浏览 1323个赞
这是一个JavaScript代码条使用的函数,在很多语言里都有类似的函数,用于输出所有的变量function var_dump( objElement, intLimit, intDepth ){ intDepth = intDepth?intDepth:0; intLimit = intLimit?intLimit:1; ……继续阅读 » 水墨上仙 4年前 (2021-01-15) 1705浏览 1282个赞
JavaScript的大量字符串链接,如果直接使用加号链接,其实是非常消耗性能的,虽然现在的浏览器如firefox,chrome都会自动对其优化,但是我们在编程的时候还是尽量避免大量字符串直接用加号链接,尽量使用堆栈数组//直接使用加号链接字符串,慢var string = 'abc'; string += '……继续阅读 » 水墨上仙 4年前 (2021-01-15) 2081浏览 333个赞
JavaScript定义变量也和性能有关,看看下面的代码你就明白了,只是把变量声明换了个地方就可以让代码变快//未优化的代码,很慢for(var i = 0; i < 1000; i++){var my_variable = 'This is my variable';// Do something with my_va……继续阅读 » 水墨上仙 4年前 (2021-01-15) 2384浏览 483个赞
下面的代码通过Tkinter制作windows窗口界面,然后时间了一个简单的倒计时功能,代码可以直接运行# Countdown using Tkinter from Tkinter import *import timeimport tkMessageBoxclass App: def __init__(self,master……继续阅读 » 水墨上仙 4年前 (2021-01-13) 1478浏览 2206个赞
python获得文件扩展名import os.path def file_extension(path): return os.path.splitext(path)[1] ……继续阅读 » 水墨上仙 4年前 (2021-01-13) 2085浏览 1417个赞
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……继续阅读 » 水墨上仙 4年前 (2021-01-13) 2626浏览 1144个赞
python删除整个目录(目录非空),os.rmdir()只能删除空目录,下面的函数可以删除整个非空目录import osimport shutildef CleanDir( Dir ): if os.path.isdir( Dir ): paths = os.listdir( Dir ) for pa……继续阅读 » 水墨上仙 4年前 (2021-01-13) 1917浏览 1833个赞
python Image.blend ValueError: images do not matchfrom PIL import Image def blend_two_images(): img1 = Image.open( "bridge.png ") img1 = img1.convert(……继续阅读 » 开心洋葱 4年前 (2020-12-02) 2275浏览 5评论2945个赞
python 通关sleep函数等待到明天再执行def waitToTomorrow(): """Wait to tommorow 00:00 am""" tomorrow = datetime.datetime.replace(datetime.datetime.now……继续阅读 » 水墨上仙 4年前 (2020-11-25) 1514浏览 1936个赞
有些JS是可以后加载的,如果一直等待JS加载完成可能非常影响网页上的其它功能实现,比如计数器一类的,jQuery可以对JS进行动态加载。方法1:$.getscript("test.js");方法2:function loadjs(file){ var head = $('head').remo……继续阅读 » 水墨上仙 4年前 (2020-11-25) 1299浏览 2672个赞
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 = ……继续阅读 » 水墨上仙 4年前 (2020-11-18) 1375浏览 1016个赞
503 : HTTP Error 503……继续阅读 » 开心洋葱 4年前 (2020-11-17) 2772浏览 0评论694个赞
### 首先登陆mysql shell$ mysql -u root -h 127.0.0.1 -p$密码输入### 查看mysql中现在执行的 所有线程mysql>show processlist; 线程id 登陆用户 主机 ……继续阅读 » 开心洋葱 4年前 (2020-11-16) 2574浏览 0评论216个赞
Python遍历字符串中的每一个字符直接用for 语句#遍历字符串a = 'asd'for q in a: print(q)# 输出结果为asd ……继续阅读 » 水墨上仙 4年前 (2020-11-16) 3154浏览 2247个赞
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……继续阅读 » 水墨上仙 4年前 (2020-11-16) 1172浏览 1912个赞
python 计算字符串长度,一个中文算两个字符,先转换成utf8,然后通过计算utf8的长度和len函数取得的长度,进行对比即可知道字符串内中文字符的数量,自然就可以计算出字符串的长度了。来源:http://www.75271.comvalue=u'脚本12'length = len(value)utf8_length = ……继续阅读 » 水墨上仙 4年前 (2020-11-16) 1991浏览 107个赞
python从网络端口读取文本数据# To test it with netcat, start the script and execute:# # echo "Hello, cat." | ncat.exe 127.0.0.1 12345#import socketHOST = 'localhos……继续阅读 » 水墨上仙 4年前 (2020-11-16) 1888浏览 2103个赞
windows下通过批处理获得本机mac地址@ECHO OFF:: Check OS versionIF NOT "%OS%"=="Windows_NT" GOTO SyntaxSETLOCAL:: Check command line argumentsIF NOT "%~2"……继续阅读 » 水墨上仙 4年前 (2020-11-16) 1607浏览 1526个赞
转自: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++的互操作性的问题,假如……继续阅读 » 水墨上仙 4年前 (2020-11-16) 1412浏览 706个赞
回文,亦称回环,是正读反读都能读通的句子,亦有将文字排列成圆圈者,是一种修辞方式和文字游戏。下面的代码用于检测一个字符串是否是回文/**检测回文串: * 先判断该字符的第一个和最后一个字符是否相等。如果相等,检查第二个字符和倒数第二个字符 * 是否相等。这个过程继续进行,直到出现不配陪的情况或者字符串的所有字符都检验完了。当字 ……继续阅读 » 水墨上仙 4年前 (2020-11-16) 2293浏览 1610个赞
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……继续阅读 » 水墨上仙 4年前 (2020-11-16) 2841浏览 295个赞
python比较两段文本的不同之处# find the difference between two texts# tested with Python24 vegaseat 6/2/2005import difflibtext1 = """The World's Shortest Books:……继续阅读 » 水墨上仙 4年前 (2020-11-16) 2627浏览 303个赞
C++通过递归进行回文判断#include using namespace std; //将一整数逆序后放入一数组中(要求递归实现) int IsRound(char *str,int len) { if(*str==*(str+len-1)) return IsRound(str+1,len-2); if(le……继续阅读 » 水墨上仙 4年前 (2020-11-16) 3123浏览 434个赞
python获取一组汉字拼音的首字母来源:http://wangwei007.blog.51cto.com/68019/983289作者:lover007#!/usr/bin/env python # -*- coding: utf-8 -*- def multi_get_letter(str_input): if ……继续阅读 » 水墨上仙 4年前 (2020-11-13) 3086浏览 371个赞
python监控本机cpu的利用百分比情况import wmiimport timec = wmi.WMI()while True: for cpu in c.Win32_Processor(): timestamp = time.strftime('%a, %d %b %Y %H:%M:%S',……继续阅读 » 水墨上仙 4年前 (2020-11-13) 1883浏览 1321个赞
python自动连接ssh的代码#!/usr/bin/python#-*- coding:utf-8 -*-import sys, time, ostry: import pexpectexcept ImportError: print """ You must insta……继续阅读 » 水墨上仙 4年前 (2020-11-13) 2388浏览 1849个赞
下面这段代码意思是,如果b为None则c等于a,否则c=b,用python写起来就容易多了a=100b=50c=a if b is None else bprint(c)#输出结果为50,这段代码相当于if b is None: c = aelse: c = b ……继续阅读 » 水墨上仙 4年前 (2020-11-13) 1778浏览 1760个赞
想sqlite插入一条记录后,马上获得自动生成的id编号的方法connection=sqlite3.connect(':memory:')cursor=connection.cursor()cursor.execute('''CREATE TABLE foo (id integer primary ……继续阅读 » 水墨上仙 4年前 (2020-11-13) 1714浏览 1168个赞
微信抽奖签到墙源码,年会,某宝买的源码–已经配置完成了,源码没问题,可直接用蓝奏云下载地址:问题1、浏览器版本不兼容问题,在首页文件里面把注释去掉就好了问题2、签到跳转主页问题,原因:未绑定公众号。解决办法:1、绑定公众号,要企业认证的那种;2、看置顶楼层,提供有解决办法。问题3、各种代码报错问题。解决办法:重新安装,检查是否设置错误即……继续阅读 » 开心洋葱 4年前 (2020-11-09) 2843浏览 13评论1890个赞
DSShop v3.0.2 单用户TP5框架B2C开源商城源码源码介绍DSShop商城系统是一套完善的B2C(单用户商城)解决方案。系统pc端后台使用国内优秀开源框架THinkPHP,基于PHP+MySQL开发,采用B/S架构,wap端使用vue.js构造,依据6年电商经验打造出的一套开源的B2C电子商务系统。DSShop商城系统技术评价1、B/S架构……继续阅读 » 开心洋葱 4年前 (2020-11-09) 3165浏览 0评论478个赞
多端B2C单用户整站源码,支持PC+H5+小程序,支持小程序直播,丰富的营销功能源码仅供学习研究,商业用途请支持正版!本地环境:nginx+php7.2+mysql5.6(其他环境自行测试)测试截图:下载地址: 解压密码:关注公众号 回复:解压密码……继续阅读 » 开心洋葱 4年前 (2020-11-09) 1435浏览 0评论1270个赞
JavaScript判断浏览器是否是IEvar isMSIE = /*@cc_on!@*/0;if (isMSIE) { // do IE-specific things} else { // do non IE-specific things} ……继续阅读 » 水墨上仙 4年前 (2020-11-06) 2414浏览 1998个赞
JavaScript不要在for循环语句里使用计算表达式和函数//慢for(var i = 0; i < my_array.length; i++)//也很慢for(var i = 0; i < myMethod(); i++)//快var length = my_array.length;for(var i = 0; ……继续阅读 » 水墨上仙 4年前 (2020-11-06) 1935浏览 1861个赞
一段简单的js代码,让浏览器自动点击按钮<script type="text/javascript"> function init(){ document.getElementById('button1').click(); } onl……继续阅读 » 水墨上仙 4年前 (2020-11-06) 1657浏览 2209个赞
child module ….pom.xml does not exista.注意module的名称是否正确,有时候命名问题会导致找不到项目的b.注意一开始项目命名的规则问题注意一开始项目命名的规则问题报错信息:[INFO] [INFO] --- maven-assembly-plugin:2.6:single (app) @ api ---……继续阅读 » 开心洋葱 5年前 (2020-05-09) 2326浏览 0评论2558个赞
此代码主要是为了演示如何通过按钮来更新grid的数据import wx, wx.gridclass GridData(wx.grid.PyGridTableBase): _cols = "a b c".split() _data = [ "1 2 3".split(), ……继续阅读 » 水墨上仙 5年前 (2020-04-13) 1210浏览 614个赞
Mytop是用于MySQL数据库的免费开放源代码命令行监视软件。它的外观类似于Linux/Unix中的“ top”命令。……继续阅读 » 醉落红尘 5年前 (2020-03-08) 2190浏览 0评论1345个赞
历年中国银行贷款基础利率(LPR)历史数据历年中国银行贷款基础利率(LPR)历史数据……继续阅读 » 开心洋葱 5年前 (2020-03-04) 2802浏览 0评论2243个赞
在python脚本内运行linux命令#/usr/bin/env pythonimport subprocessclass RunCmd(object): def cmd_run(self, cmd): self.cmd = cmd subprocess.call(self.cmd, shell=Tru……继续阅读 » 水墨上仙 6年前 (2019-09-03) 2085浏览 2142个赞
Python输出两个字符串中相同的字符,计算两个字符串的交集import setsmagic_chars = sets.Set('abracadabra')poppins_chars = sets.Set('supercalifragilisticexpialidocious')print '&……继续阅读 » 水墨上仙 6年前 (2019-09-03) 2665浏览 2167个赞
python提供了非常方便的日志模块#-*- coding:utf-8 -*-import logging# 配置日志信息logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-……继续阅读 » 水墨上仙 6年前 (2019-09-03) 1333浏览 2195个赞
split(string[, maxsplit]) | re.split(pattern, string[, maxsplit]):按照能够匹配的子串将string分割后返回列表。maxsplit用于指定最大分割次数,不指定将全部分割。import re p = re.compile(r'\d+')print p.spli……继续阅读 » 水墨上仙 6年前 (2019-09-03) 1441浏览 1701个赞