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) 1764浏览 0评论2985个赞
python计算数组、元祖等列表元素的和print( sum([1,2,3])) 返回值:6……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3028浏览 1401个赞
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) 3799浏览 2745个赞
def isAString(anobj):return isinstance(anobj, basestring)def isAString(anobj): return isinstance(anobj, basestring)……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2604浏览 187个赞
multipart/form-data类型的POST实体结构相对来说(常规的POST正文采用application/x-www-form-urlencoded格式)比较复杂,它常用于文件上传。下面是一个multipart/form-data格式的POST实体示例-----------------------------114782935826962 ……继续阅读 » 水墨上仙 7年前 (2019-08-08) 1718浏览 380个赞
python写日志的封装类# encoding:utf-8import sysimport loggingimport time def writeLog(message): logger=logging.getLogger() filename = time.strftime('%Y-%m-%d'……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2387浏览 247个赞
python链接Oracle数据库的代码,需要引用cx_Oracle库#coding=UTF-8 import cx_Oracle def hello(): '''Hello cx_Oracle示例: 1)打印数据库版本信息. 2)查询表数据.'……继续阅读 » 水墨上仙 7年前 (2019-08-08) 1627浏览 2158个赞
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) 2753浏览 2120个赞
python正则查找所有匹配的字符串import re p = re.compile(r'\d+')print p.findall('one1two2three3four4') ### output #### ['1', '2', '3……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2595浏览 2031个赞
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) 2494浏览 641个赞
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) 2478浏览 1957个赞
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) 2487浏览 2578个赞
由于Python设计的限制(我说的是咱们常用的CPython)。最多只能用满1个CPU核心。Python提供了非常好用的多进程包multiprocessing,你只需要定义一个函数,Python会替你完成其他所有事情。借助这个包,可以轻松完成从单进程到并发执行的转换。1、新建单一进程如果我们新建少量进程,可以如下:import multiproces……继续阅读 » 水墨上仙 7年前 (2019-08-08) 1689浏览 1106个赞
在2.6才开始使用multiprocessing 是一个使用方法类似threading模块的进程模块。允许程序员做并行开发。并且可以在UNIX和Windows下运行。通过创建一个Process 类型并且通过调用call()方法spawn一个进程。下面是该模块的一个测试程序。效果非常好#!/usr/bin/env python#coding=utf-……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3113浏览 1310个赞
python subprocess模块 监控子进程的2种方式 忙等待和立即返回同时设置子进程超时时间一:循环 忙等 子进程结束import subprocess import os import time tt = '555' cmd = "python /home/1……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3083浏览 751个赞
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) 2740浏览 2099个赞
Advanced Python Scheduler是一个python的定时执行任务的框架,调用无比简单,不用自己写定时器了 演示代码from apscheduler.scheduler import Schedulersched = Scheduler()@sched.i……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2185浏览 721个赞
python重命名文件代码#-*-coding:gbk-*-import oscur_path = os.getcwd()lists = os.listdir( cur_path )for f in lists: if f != 'ren.py': print cur_path ……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2463浏览 610个赞
python通过xmlrpc进行远程调用的范例演示服务器端代码# -*- coding: utf-8 -*-import SimpleXMLRPCServer#server 上面的程式碼 def Show_me_some_message(sMsg):#從遠端呼叫並且帶入參數 print "I see your call……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2137浏览 2856个赞
Go语言的string模块包含了ToLower和ToUpper函数,用于将字符串转换成小写和大写package mainimport ( "fmt" "strings")func main() { fmt.Println(strings.ToUpper("hello wo……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2566浏览 176个赞
select 语句使得一个 goroutine 在多个通讯操作上等待。select 会阻塞,直到条件分支中的某个可以继续执行,这时就会执行那个条件分支。当多个都准备好的时候,会随机选择一个。package mainimport "fmt"func fibonacci(c, quit chan int) { ……继续阅读 » 水墨上仙 7年前 (2019-08-08) 2063浏览 2267个赞
通过两种方式提供基于HTML模板的多变量值替换。另外附加一个数组迭代的示例。 传入map实现多值替换package mainimport ( "html/template" "os")func main() { t,……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3195浏览 2617个赞
JavaScript转向跳转(redirect)<script type="text/javascript"><!-- window.location = "http://www.google.com/" //--></script> ……继续阅读 » 水墨上仙 7年前 (2019-08-08) 3150浏览 999个赞