自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(39)
  • 收藏
  • 关注

原创 Python and Ruby

Python 和 Ruby 的相同点:     都强调语法简单,都具有更一般的表达方式。    Python 是缩进,Ruby 是类 Basic 的表达。    都大量减少了符号。     都是动态数据类型。    都是有丰富的数据结构。     都具有 C 语言扩展能力,都具有可移植性,比 perl 的可移植性更好。也都可以作为嵌入语言。     都是面向对象的语言,都可以作为大...

2008-10-06 16:13:28 113

原创 What's Pythonic?

If you're not willing to read English, here is a translation:http://blog.csdn.net/lanphaday/archive/2008/08/03/2762251.aspx  What the heck does "pythonic" mean? This was a question asked a few...

2008-09-24 14:30:28 172

原创 Feel Pythonic: The Zen of Python

Let's feel about what "pythonic" is!  >>> import thisThe Zen of Python, by Tim PetersBeautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Compl...

2008-09-24 14:20:25 126

原创 What's WiMAX?

究竟何谓WiMAX? WiMAX全称为World Interoperability for Microwave Access,即全球微波接入互操作性。WiMAX的另一个名字是802.16。 IEEE802.16标准,又称WiMAX,或广带无线接入(Broadband Wireless Access,BWA)标准。它是一项无线城域网(WMAN)技术,是针对微波和毫米波频段提出的一种新的空中接口标准。...

2008-09-24 13:20:18 139

原创 Python 中使用 pyrex 生成 Linux 可执行文件

    这个问题是相当有意义的,如果有了比较好的方法,Python 完全可以用来开发商业软件,而不用担心源代码泄露。    前两天我在网上看了看,有很多的人在问这个问题。大部分的人都在用 py2exe,这是个对 Python 程序打包的东东,实际上只是在 Python 程序中找 出依赖的模块,然后发布这个程序。好处在于可以让这个程序脱离 Python 的环境来执行,不用安装 Python 解释器。...

2008-08-15 14:30:27 508

原创 Python 模块之 threading: 在 Python 中使用多线程

    Python 是支持多线程的,并且是 native 的线程。主要是通过 thread 和 threading 这两个模块来实现的。thread是比较底层的模块,threading 是对 thread 做了一些包装的,可以更加方便的被使用。这里需要提一下的是 Python 对线程的支持还不够完善,不能利用多 CPU,但是下个版本的 Python 中已经考虑改进这点,让我们拭目以待。    t...

2008-08-15 14:25:52 124

原创 Python 模块之 ConfigParser: 用 Python 解析配置文件

    在程序中使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在 Python 里更是如此,在官方发布的库中就包含有做这件事情的库,那就是 ConfigParser,这里简单的做一些介绍。    ConfigParser 解析的配置文件的格式比较象 ini 的配置文件格式,就是文件中由多个 section 构成,每个 section 下又有多个配置项,比如: [db...

2008-08-15 14:23:11 109

原创 Python 中怎么 copy 文件和目录

>>> import shutil>>> dir(shutil)['Error', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '_samefile', 'abspath', 'copy', 'copy2', 'copyfile', 'copyfileobj', 'copym...

2008-08-15 14:20:14 167

原创 Python 中使用 FTP

import ftplibftp = ftplib.FTP()ftp.connect("ftp.freebsdchina.org",21)ftp.login("anonymous", "123")ftp.dir()ftp.quit() 下载用这个:ftp.retrbinary('RETR '+filename, open(filename,'wb').write) 上传用这个...

2008-08-15 14:19:09 158

原创 Python 中列出目录中所有文件的方法

import string, os, sysdir = '/var'print '----------- no sub dir'files = os.listdir(dir)for f in files: print dir + os.sep + fprint '----------- all dir'for root, dirs, files in os.walk(d...

2008-08-15 14:17:16 870

原创 用 C 为 Python 写个简单的模块

Python 语言是支持用 C 来它写模块的,其实现有的很多模块也是用 C 写的。这里我做个简单的介绍。先决条件:1. 在 linux 上编写时,需要自己编译出 Python的动态连接库。也就是要有 libpython2.5.so 这样的东西。2. 在 windows 上时,则需要 mingw 这个编译环境。其实只要你安装了 Dev-Cpp 就有了。当然还安装了 windows 版的 Python...

2008-08-15 14:09:41 116

原创 Amusing Python 2: range/xrange

这两个基本上都是在循环的时候用。for i in range(0, 100): print ifor i in xrange(0, 100): print i  这两个输出的结果都是一样的,实际上有很多不同,range会直接生成一个list对象:>>> a = range(0, 10)>>> type(a)<type ...

2008-08-15 14:03:07 92

原创 在 Python 代码中进行自动测试

Python 有一个叫 doctest 的模块,很有意思,它可以让你在代码的注释中写入一些特殊的注释,这些注释是测试程序。Python 可以自动对它进行测试。import doctestdef myadd(a, b): ''' >>> myadd(1, 2) 3 >>> myadd(4, 5) 9 ''' ...

2008-08-15 13:49:07 149

原创 Python2.5 中的新类型:set (集合)

Python2.5 中新增加了集合内容,让我想起了初中数学。看看:>>> b = set()>>> b.add(1)>>> b.add(2)>>> b.add(3)>>> b.add(4)>>>>>>

2008-08-15 13:46:56 89

原创 Amazing Python 3: "@"

1. This an interesting usage that I don't know how to call it.  See example:def hehe(tt): return 'hehe'+tt()@hehedef test(): return 'test'print test The output is same as: def hehe...

2008-08-15 13:44:31 101

原创 用 Python 下载网页,超级简单!

from urllib import urlopenwebdata = urlopen("").read()print webdata From http://www.pythonid.com/html/fenleiwenzhang/network/20070910/173.html See more in "Dive Into Python"

2008-08-15 13:42:14 253

原创 Amusing Python 1: "*"

Take a look at the three different "lists" below, guess the outputs:(a)>>> lists = [ [], [], [] ]>>> lists[[], [], []]>>> lists[1].append("Hi there!")>&gt

2008-07-25 15:15:19 117

原创 Amazing Python 2: "exec/eval/repr"

1. exec:       Executing command from string.class PlayerBase(): player_name = None def talk(self): print self.player_name, ": It takes five." class Kobe(Pl...

2008-07-25 14:35:38 87

原创 Amazing Python 1: "yield"

"yield" is used for Generater (below 2.2) or seperately (2.2 or above) in Python."yield" mainly works as "return", but it makes a function able to have multiple return values step by step. Al...

2008-07-23 11:37:49 130

“飞鸽传书” in Ubuntu

Download 飞鸽传书 (IP Messager) from here:http://www.ipmsg.org/archive/g2ipmsg-0.9.5.tar.gzOpen a terminal:$ tar zxf g2ipmsg-0.9.5.tar.gz$ cd g2ipmsg-0.9.5/$ sudo apt-get install build-essen...

2008-07-01 12:20:27 268

Easy PyMaemo developping on PC using SSH/SCP

Wanna develop Maemo programs in Linux without Maemo SDK? Or even in Windows?  Nothing is impossible if you know Python! Working on PyMaemo, all we need are:1. N800 with python2.5-runtime.2. A pc w...

2008-06-29 01:01:34 124

[Copy] UDP Broadcasting Using PySocket

Socket Server:# -*- coding: cp936 -*-"""广播服务器,接收来自广播的消息,并进行应答设置socket选项:SO_BROADCAST"""import sockethost = ""port = 50000s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)s.setsockopt(soc...

2008-06-10 12:04:46 83

Executing system commands in N800 application

Basically, just use "os.system(str)". For example:import oscmd = 'ls'os.system(cmd) However, when we need to be root, e.g., running "sudo apt-get update", troubles come out, since a UI applicatio...

2008-05-09 17:18:45 87

Syntax highlights of Python in UltraEdit

Open \UEStudio 06\wordfile.txt (or find in UE menu: 高级->配置->编辑器显示->语法加亮->打开). Append following to the file: (the "/L14" in line one must be changed to the existing last number in your ow...

2008-05-09 16:39:57 87

About JavaScript, JScript, JSP

1、Java, JavaScript, JScript, JSP 语言开发者类型                编译位置    动/静其它JavaSun面向对象编程语言需要客户端静态前身Oak语言JavaScriptSun, Netscape基于对象,事件驱动,脚本语言不需要客户端静态简称JS, 介于Java与HTML之间JScriptMicrosoft基于对象,事件驱动,脚本语言不需要客户端静态...

2008-01-09 19:37:24 115

When apt-get shows "Media change: please insert the disc..."

[size=11]It is the line in the source list:[quote][color=blue]deb cdrom: ...[/color][/quote]that makes apt-get ask users to insert the Ubuntu disc during installation.Edit file "/etc/apt/sources...

2007-12-20 12:12:43 80

Video sharing in (W)LAN using VLC

[size=11]Find the latest VLC from:[url]http://download.videolan.org/pub/videolan/vlc/0.8.6d/win32/[/url]Both server and client are using vlc-0.8.6d here.[/size][b][size=16]Server:[/size][/b]...

2007-12-12 18:22:28 91

[Copy] 有限状态自动机(FSM)的简单实现

[i][color=red][size=11]Sometimes, a quite simple concept comes out with lots of related theories that make beginners have to spend an exausting time before figure out the basic one. Watching something...

2007-12-12 11:17:15 212

[Copy] Netlink Socket

[b][size=14]简介[/size][/b]Netlink 是一种特殊的 socket,它是 Linux 所特有的,类似于 BSD 中的AF_ROUTE 但又远比它的功能强大,目前在最新的 Linux 内核(2.6.14)中使用netlink 进行应用与内核通信的应用很多,包括:路由 daemon(NETLINK_ROUTE),1-wire 子系统(NETLINK_W1),用户态 soc...

2007-12-11 12:07:06 101

[Copy] Why and How to Use Netlink Socket

[color=red][i]作者:Kevin He,2005-01-05 原文地址:[url]http://www.linuxjournal.com/article/7356[/url]译者:Love. Katherine,2007-03-23译文地址:[url]http://blog.csdn.net/lovekatherine/archive/2007/03/23/153926...

2007-12-11 10:52:18 128

[Copy] Linux C Socket Quick Reference

[color=red][size=14][i]See more in book "Linux C Function".[/i][/size][/color][b][size=18]1. accept(接受socket连线) [/size][/b]相关函数 socket,bind,listen,connect 表头文件 #include#include 定义函数...

2007-12-11 09:49:55 94

Installing Maemo on Ubuntu manually

This article takes Maemo2.2 and Ubuntu6.10 for example. However, what we need to install another edition of Maemo platform is just to change the rootstrap gived below. As for Ubuntu, I think those abo...

2007-12-10 09:22:58 111

Using apt-get in scratchbox

[size=13]In a new installed scratchbox, on which Maemo SDK is based on, there is a DNS problem.While:[/size][code][sbox-SDK_PC: ~] fakeroot apt-get update[/code][size=13]We see:[/size][quote]T...

2007-12-07 18:19:00 107

Setting a proxy inside scratchbox

[code][sbox-SDK_PC: ~] export http_proxy=http://username:password@proxyaddr:port[/code][size=13]Remember to run it everytime you start a scratchbox."ftp_proxy" is in the same way.Looks eas...

2007-12-07 18:10:59 70

Installing packages to N800 from source

For example, get a package called "gst-plugins-good0.10":Terminal 代码 [sbox-SDK_ARMEL: ~] fakeroot apt-get update    [sbox-SDK_ARMEL: ~] fakeroot apt-get build-dep gst-plugins-good0.10   ...

2007-12-07 17:47:01 91

When Ubuntu6.10 cannot install vmware-tools

[size=13]The installation stops at:[/size][quote]What is the location of the directory of C header files that match your running kernel? [/usr/src/linux/include][/quote][size=13]What...

2007-12-07 16:37:55 69

Bewildering service names of python application on maemo

A simple file structure of python applications on maemo/n800:hellowordhelloword.desktophelloword.servicehelloword.pngsetup.pyNote: 1. Main source file helloworld is written in python, but it ...

2007-12-07 15:51:35 82

Installing python on maemo and Nokia N800

Python2.5 is needed when using pygtk on maemo, otherwise the default python2.3 may be enough.Add "deb http://repository.maemo.org/extras bora free non-free" to /scratchbox/users/maemo/target/SDK_ARME...

2007-12-07 15:07:27 151

A problem in unpacking strings

If a string to be packed is shorter than its format, it'll be followed by '\x00's when unpacked.One example, in which every length of the string fits the format:python 代码 >>> import ...

2007-12-07 11:11:49 74

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除