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',……继续阅读 » 水墨上仙 6年前 (2020-11-13) 2358浏览 2216个赞
python自动连接ssh的代码#!/usr/bin/python#-*- coding:utf-8 -*-import sys, time, ostry: import pexpectexcept ImportError: print """ You must insta……继续阅读 » 水墨上仙 6年前 (2020-11-13) 1796浏览 2221个赞
下面这段代码意思是,如果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 ……继续阅读 » 水墨上仙 6年前 (2020-11-13) 1759浏览 2878个赞
想sqlite插入一条记录后,马上获得自动生成的id编号的方法connection=sqlite3.connect(':memory:')cursor=connection.cursor()cursor.execute('''CREATE TABLE foo (id integer primary ……继续阅读 » 水墨上仙 6年前 (2020-11-13) 3535浏览 509个赞
微信抽奖签到墙源码,年会,某宝买的源码–已经配置完成了,源码没问题,可直接用蓝奏云下载地址:问题1、浏览器版本不兼容问题,在首页文件里面把注释去掉就好了问题2、签到跳转主页问题,原因:未绑定公众号。解决办法:1、绑定公众号,要企业认证的那种;2、看置顶楼层,提供有解决办法。问题3、各种代码报错问题。解决办法:重新安装,检查是否设置错误即……继续阅读 » 开心洋葱 6年前 (2020-11-09) 2260浏览 13评论2141个赞
DSShop v3.0.2 单用户TP5框架B2C开源商城源码源码介绍DSShop商城系统是一套完善的B2C(单用户商城)解决方案。系统pc端后台使用国内优秀开源框架THinkPHP,基于PHP+MySQL开发,采用B/S架构,wap端使用vue.js构造,依据6年电商经验打造出的一套开源的B2C电子商务系统。DSShop商城系统技术评价1、B/S架构……继续阅读 » 开心洋葱 6年前 (2020-11-09) 2586浏览 0评论1689个赞
多端B2C单用户整站源码,支持PC+H5+小程序,支持小程序直播,丰富的营销功能源码仅供学习研究,商业用途请支持正版!本地环境:nginx+php7.2+mysql5.6(其他环境自行测试)测试截图:下载地址: 解压密码:关注公众号 回复:解压密码……继续阅读 » 开心洋葱 6年前 (2020-11-09) 2673浏览 3评论956个赞
JavaScript判断浏览器是否是IEvar isMSIE = /*@cc_on!@*/0;if (isMSIE) { // do IE-specific things} else { // do non IE-specific things} ……继续阅读 » 水墨上仙 6年前 (2020-11-06) 3567浏览 685个赞
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; ……继续阅读 » 水墨上仙 6年前 (2020-11-06) 2079浏览 2203个赞
一段简单的js代码,让浏览器自动点击按钮<script type="text/javascript"> function init(){ document.getElementById('button1').click(); } onl……继续阅读 » 水墨上仙 6年前 (2020-11-06) 2309浏览 2575个赞
child module ….pom.xml does not exista.注意module的名称是否正确,有时候命名问题会导致找不到项目的b.注意一开始项目命名的规则问题注意一开始项目命名的规则问题报错信息:[INFO] [INFO] --- maven-assembly-plugin:2.6:single (app) @ api ---……继续阅读 » 开心洋葱 6年前 (2020-05-09) 2645浏览 0评论447个赞
此代码主要是为了演示如何通过按钮来更新grid的数据import wx, wx.gridclass GridData(wx.grid.PyGridTableBase): _cols = "a b c".split() _data = [ "1 2 3".split(), ……继续阅读 » 水墨上仙 7年前 (2020-04-13) 1804浏览 2831个赞
Mytop是用于MySQL数据库的免费开放源代码命令行监视软件。它的外观类似于Linux/Unix中的“ top”命令。……继续阅读 » 开心洋葱 7年前 (2020-03-08) 2124浏览 0评论1660个赞
历年中国银行贷款基础利率(LPR)历史数据历年中国银行贷款基础利率(LPR)历史数据……继续阅读 » 开心洋葱 7年前 (2020-03-04) 2929浏览 0评论905个赞
在python脚本内运行linux命令#/usr/bin/env pythonimport subprocessclass RunCmd(object): def cmd_run(self, cmd): self.cmd = cmd subprocess.call(self.cmd, shell=Tru……继续阅读 » 水墨上仙 7年前 (2019-09-03) 2666浏览 1741个赞
Python输出两个字符串中相同的字符,计算两个字符串的交集import setsmagic_chars = sets.Set('abracadabra')poppins_chars = sets.Set('supercalifragilisticexpialidocious')print '&……继续阅读 » 水墨上仙 7年前 (2019-09-03) 3700浏览 2614个赞
python提供了非常方便的日志模块#-*- coding:utf-8 -*-import logging# 配置日志信息logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-……继续阅读 » 水墨上仙 7年前 (2019-09-03) 2015浏览 2687个赞
split(string[, maxsplit]) | re.split(pattern, string[, maxsplit]):按照能够匹配的子串将string分割后返回列表。maxsplit用于指定最大分割次数,不指定将全部分割。import re p = re.compile(r'\d+')print p.spli……继续阅读 » 水墨上仙 7年前 (2019-09-03) 1712浏览 1460个赞
python 中map函数使用范例代码# build a dictionary that maps the ordinals from 32 to 255# to their ASCII character equivalents eg. 33: '!'# (note that 32 and 160 are spaces)……继续阅读 » 水墨上仙 7年前 (2019-09-03) 1927浏览 654个赞
python统计文本文件内单词数量# count lines, sentences, and words of a text file# set all the counters to zerolines, blanklines, sentences, words = 0, 0, 0, 0print '-' * 50tr……继续阅读 » 水墨上仙 7年前 (2019-09-03) 1792浏览 2958个赞
Go语言获取数组长度// getting the length of an array is silly, because the length is part of the array's static typemyArray := [3]int{1, 2, 3}fmt.Println(len(myArray)) // prints 3……继续阅读 » 水墨上仙 7年前 (2019-09-03) 1859浏览 2049个赞
创建游戏$ cocos new -p com.yt.supermario -d ~/yt/game/ -l cpp supermario> 拷贝模板到 /Users/yt/yt/game/supermario> 拷贝 cocos2d-x ...> 替换文件名中的工程名称,'HelloCpp' 替换为 &……继续阅读 » 开心洋葱 7年前 (2019-09-03) 3502浏览 0评论1015个赞
Go语言排序与接口代码演示import "fmt"type Sorter interface { Len() int Less(i, j int) bool Swap(i, j int)}type Xi []inttype Xs []stringfunc (p Xi) Len() int { ……继续阅读 » 水墨上仙 7年前 (2019-09-03) 1551浏览 2139个赞
Go语言写入字符串到文件代码package main import "fmt"import "os"func main() { fileName := "test.dat" dstFile,err := os.Create(fileName) if err!=nil……继续阅读 » 水墨上仙 7年前 (2019-09-03) 2697浏览 2207个赞
go语言里使用scp的范例// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_workspackage mainimport ( "code.google.com/p/go.crypto/ssh" "crypto" &q……继续阅读 » 水墨上仙 7年前 (2019-09-03) 3165浏览 2944个赞
本范例演示了JS中如何通过String.prototype自定义字符串操作协议,本代码定义了两个操作方法,一个用于清除html标签,一个用来转换html标签,都非常有用String.prototype.stripslashes = function(){ return this.replace(/<.*?>/g, '……继续阅读 » 水墨上仙 7年前 (2019-09-03) 2165浏览 2088个赞
实现示例:sql: state=11 and (aa=2 or bb=3)mongodb: { state : “11” , $or : [ { aa : 2 } , { bb : 3 } ] }BasicDBObject whereEnd = new BasicDBObject();whereEnd.put(“s……继续阅读 » 开心洋葱 7年前 (2019-08-22) 3479浏览 0评论2691个赞
angular8 添加 消息弹窗提示错误There is no directive with “exportAs” set to “bs-modal” Uncaught Error: Template parse errors:There is no directive with “export……继续阅读 » 开心洋葱 7年前 (2019-08-15) 3103浏览 0评论828个赞
start.spring.io替换国内地址start.75271.com解决spring boot start.spring.io 不能访问使用http://start.spring.io/ 生成工程目前不能访问,可以访问国内地址http://start.75271.comstart.spring.io 访问不了怎么办?这个可以这么解决Spring……继续阅读 » 开心洋葱 7年前 (2019-08-09) 2694浏览 0评论2810个赞
import org.apache.commons.codec.binary.Base64; public class c { public static void main(String[] args) throws Exception { // String base64Str = // &quo……继续阅读 » 开心洋葱 7年前 (2019-08-08) 2649浏览 0评论2675个赞
python计算数组、元祖等列表元素的和print( sum([1,2,3])) 返回值:6……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2505浏览 2624个赞
python遍历字符串中的字符word = raw_input("Enter a word: ")print "\nHere's each letter in your word:"for letter in word: print letter……继续阅读 » 水墨上仙 7年前 (2019-08-08) 4308浏览 2098个赞
def isAString(anobj):return isinstance(anobj, basestring)def isAString(anobj): return isinstance(anobj, basestring)……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2671浏览 2762个赞
multipart/form-data类型的POST实体结构相对来说(常规的POST正文采用application/x-www-form-urlencoded格式)比较复杂,它常用于文件上传。下面是一个multipart/form-data格式的POST实体示例-----------------------------114782935826962 ……继续阅读 » 水墨上仙 7年前 (2019-08-08) 1890浏览 150个赞
python写日志的封装类# encoding:utf-8import sysimport loggingimport time def writeLog(message): logger=logging.getLogger() filename = time.strftime('%Y-%m-%d'……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2899浏览 2076个赞
python链接Oracle数据库的代码,需要引用cx_Oracle库#coding=UTF-8 import cx_Oracle def hello(): '''Hello cx_Oracle示例: 1)打印数据库版本信息. 2)查询表数据.'……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2414浏览 2180个赞
python 给目录下的图片批量加水印water.py 放到 图片文件夹里 然后cd 到当前文件夹 python water.py#coding=utf-8import Imageimport os#print list[0]#exit()def getlogo(x1,y1): im =Image.open("./&qu……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2499浏览 382个赞
python正则查找所有匹配的字符串import re p = re.compile(r'\d+')print p.findall('one1two2three3four4') ### output #### ['1', '2', '3……继续阅读 » 水墨上仙 7年前 (2019-08-08) 4314浏览 2035个赞
python zip和unzip数据# zipping and unzipping a string using the zlib module# a very large string could be zipped and saved to a file speeding up file writing time # and later rel……继续阅读 » 水墨上仙 7年前 (2019-08-08) 1599浏览 1226个赞
wxpython GUI界面显示jpg图片# show a jpeg (.jpg) image using wxPython, newer coding style# two different ways to load and display are given# tested with Python24 and wxPython25 veg……继续阅读 » 水墨上仙 7年前 (2019-08-08) 1621浏览 1599个赞
python将文本转换成语音# Text To Speech using SAPI (Windows) and Python module pyTTS by Peter Parente# download installer file pyTTS-3.0.win32-py2.4.exe # from: http://sourceforge.ne……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2288浏览 1624个赞
由于Python设计的限制(我说的是咱们常用的CPython)。最多只能用满1个CPU核心。Python提供了非常好用的多进程包multiprocessing,你只需要定义一个函数,Python会替你完成其他所有事情。借助这个包,可以轻松完成从单进程到并发执行的转换。1、新建单一进程如果我们新建少量进程,可以如下:import multiproces……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2661浏览 2693个赞
在2.6才开始使用multiprocessing 是一个使用方法类似threading模块的进程模块。允许程序员做并行开发。并且可以在UNIX和Windows下运行。通过创建一个Process 类型并且通过调用call()方法spawn一个进程。下面是该模块的一个测试程序。效果非常好#!/usr/bin/env python#coding=utf-……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3366浏览 685个赞
python subprocess模块 监控子进程的2种方式 忙等待和立即返回同时设置子进程超时时间一:循环 忙等 子进程结束import subprocess import os import time tt = '555' cmd = "python /home/1……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3087浏览 180个赞
python插入排序示范代码(算法)插入排序就是每一步都将一个待排数据按其大小插入到已经排序的数据中的适当位置,直到全部插入完毕. 数据演示:[1,4,2,3]第一次:[1,4,2,3]第二次:[1,4,2,3]第三次:[1,2,4,3]第四次:[1,2,3,4]代码示例如下:……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2295浏览 258个赞