ITeye博客

yuhai.china

yuhai.china · 共 67 篇文章

利用pycurl做GETMETHOD

import urllib2 import pycurl import cStringIO as _StringIO import sys import shutil import lxml.html as H import threading import StorageClient as sc import lame # http transfer limits accept_type = "*/*" connection_timeout = 500 timeout = 800 low_speed = 200 low_speed_time = 120 max_size = 2048576…

2009-03-09 10:19 · 评论(0) · HTML · FP · Windows

python转码

关键是利用unicode内部编码 主要介绍了python的编码机制,unicode, utf-8, utf-16, GBK, GB2312,ISO-8859-1 等编码之间的转换。 **常见的编码转换分为以下几种情况:** ===== unicode 转换为其它编码(GBK, GB2312等) ===== 例如:a为unicode编码 要转为gb2312。a.encode('gb2312') # -*- coding=gb2312 -*- a = u"中文" a_gb2312 = a.encode('gb2312') print a_gb2312 ===== 其它编码(utf-8,GBK)转…

2009-03-08 21:37 · 评论(0) · Python

cannot open shared object file:No such file or dir

出现这个问题是因为在编译python的时候没有把LD_LIBRARY_PATH处理好,只要在运行前指定下该变量: export LD_LIBRARY_PATH=/your/python/lib/directory 然后在运行python就可以了. 或者在编译的时候把LD_LIBRARY_PATH放进来.

2009-03-08 07:52 · 评论(0) · Python

简单树匹配

这是一种判断两棵DOM树匹配程度的方法,返回的是两棵树有相同标签节点的最大数目 def TreeMatch(A,B): med=[0,-1,-1] if A.tag!=B.tag:return med m=len(A.getchildren()) n=len(B.getchildren()) maxl=max(m,n) M=[[0 for x in range(n+1)]for y in range(m+1)] W=[[0 for x in range(n+1)]for y in range(m+1)] for i in range(1,m+1): for j in range(1,n+1)…

2009-02-24 10:15 · 评论(0) · J#

opensolaris login

User_name: jack Password: jack su password: opensolaris You cannot login as root.

2009-02-19 17:32 · 评论(0)

在python中使用sqlite3

import sqlite3 as sql con=sql.connect('e:/testdb') cur=con.cursor() cur.execute('create table users(login varchar(8),id integer)') cur.execute('insert into users values("jhon",11)') cur.execute('select * from users') for u in cur.fetchall(): print u cur.close() con.commit() con.close()

2009-02-17 13:24 · 评论(0) · Java · SQL · Python

python利用pycurl做get

import urllib2 import pycurl import cStringIO as _StringIO import sys import shutil import lxml.html as H import threading # http transfer limits accept_type = "*/*" connection_timeout = 500 timeout = 800 low_speed = 200 low_speed_time = 120 max_size = 20485760 # 10MB def get_curl(user_agent="MSIE"…

2009-02-11 10:58 · 评论(0) · HTML · FP · Windows · Python

使用python的lxml解析html

首先是安装lxml doc.xpath()返回一个满足条件的list # coding=gb2312 from lxml import * import lxml.html import urllib2 import lxml.html as H def getjarinfo(url): c=urllib2.urlopen(url) f=c.read() doc = H.document_fromstring(f) tables=doc.xpath("//table[@id='xiazai']") pinpais=doc.xpath("//td[@id='pinpai']") jixings…

2009-02-04 15:53 · 评论(0) · HTML · C · 游戏 · J# · Python

libsvm使用入门

from svm import * param = svm_parameter(kernel_type=LINEAR , C=10) prob = svm_problem([1,0],[[1,3,1],[-1,2,-1]]) m = svm_model(prob,param) print m.predict([1,0,3]) print m.predict_values_raw([1,0,3]) print m.predict_values_raw([1,2,3]) print m.predict_values_raw([-1,2,-3])

2009-01-03 18:38 · 评论(0) · C · C++ · C# · Python

windows和linux文件名互转

利用URLEncoder 和URLDecoder 可以相互转换而不会有错误

2008-12-26 17:14 · 评论(0) · Windows · Linux

java调用系统命令

必须注意,这种调用由于新开一个Process,所以是异步的。 String cmd = "MIDI0TO1 " + tmp1.getAbsolutePath() + " f:\\out.mid"; System.out.println(cmd); Process proc = Runtime.getRuntime().exec(cmd); int ret = 0; try { ret = proc.waitFor(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace…

2008-12-26 11:06 · 评论(0) · Java · F#

java读excel文件

public static void test() { int count = 16; File tmp = new File("F:\\听辩第一次\\铃音" + String.valueOf(count) + "midi-1.xls"); try { Workbook workbook = Workbook.getWorkbook(tmp); for (String sheetname : new String[] { "Sheet2" }) { Sheet sheet = workbook.getSheet(sheetname); int rows = sheet.getRows(); …

2008-12-26 11:03 · 评论(0) · Java · F# · Excel

java写excel文件

public static void createXls() throws Exception { for (int i = 13; i <= 13; i++) { File xls = new File("E:\\歌单"+String.valueOf(i)+".xls"); WritableWorkbook workbook = Workbook.createWorkbook(xls); String sixteenrootdir = "E:\\mp3-1\\铃音"; File tmp = new File("E:\\铃声\\铃音" + String.valueOf(i) + "\\唱")…

2008-12-26 11:02 · 评论(2) · Java · F# · Excel

MapReduce程序设计总结

内容稍后添加

2008-12-14 13:53 · 评论(0) · Mapreduce

Hadoop的Windows单机环境搭建

第一个关键点,配置hadoop.job.ugi参数conf.set("hadoop.job.ugi", "username,psw");

2008-12-14 13:48 · 评论(0) · Windows · Hadoop