<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>L-JH博客</title>
	<atom:link href="http://www.ljhblog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ljhblog.com</link>
	<description>L-JH博客</description>
	<lastBuildDate>Sun, 19 Feb 2012 10:07:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>python 提高效率的几个小技巧</title>
		<link>http://www.ljhblog.com/python-efficiency/</link>
		<comments>http://www.ljhblog.com/python-efficiency/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 08:56:03 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=185</guid>
		<description><![CDATA[<span style="font-size: small;"><strong>python 提高效率的几个小技巧</strong></span>

1.1. 最常见
一个最常见的速度陷坑(至少是俺在没看到网上这篇介绍时陷进去
过好些次的) 是: 许多短字串并成长字串时, 大家通常会用:

Toggle line numbers
1 shortStrs = [ str0, str1, ..., strN]
2 #N+1个字串所组成的数列
3 longStr = ”
4 for s in shortStrs: longStr += s
因为<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>里 字串是不可变的, 所以每次 longStr += s 都是将原 来的 longStr 与 str 拷贝成一个新字串, 再赋给longStr. 随着 longStr的不断增长, 所要拷贝的内容越来越长. 最后导至str0被 拷贝N+1次, str1是N次, … .

那咋办呢 ? 咱们来看看Skip Montanaro先生的解说: <a href="http://musi-cal.mojam.com/~skip/python/fastpython.html">http://musi-cal.mojam.com/~skip/python/fastpython.html</a> 及可参考一下Guido van Rossum本人的:<a href="http://www.python.org/doc/essays/list2str.html">http://www.python.org/doc/essays/list2str.html</a>

1.1.1. 找出速度瓶颈
1)首先在大家应先学会怎么去找出速度瓶颈: <a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>自带有profile
模块:

Toggle line numbers
1 import profile
2 profile.run (’想要检查的函数名()’)
就会打印出那个函数里调用了几次其它函数, 各用了多少时间, 总共用了多少时间等信息 — Nice ? 详请参阅&#60;&#60;库参考&#62;&#62;中的 profile模块的论述.

当然脑袋笨一点或是聪明一点的, 也可以用time模块中的time() 来显示系统时间, 减去上次的time()就是与它的间隔秒数了.

1.1.2. 字串相并
就头上的例子而言, 用 :

Toggle line numbers
1 longStr =”.join(shortStrs)
立马搞定, 但如果shortStrs里面不都是字串, 而包含了些数 字呢 ? 直接用join就会出错. 不怕, 这样来:

Toggle line numbers
1 shortStrs = [str(s) for s in shortStrs[i]]
2 longStr = ”.join(shortStrs)
也即先将数列中所有内容都转化为字串, 再用join.

对少数几个字串相并, 应避免用: all = str0 + str1 + str2 + str3 而用: all = ‘%s%s%s%s’ % (str0, str1, str2, str3)

1.1.3. 数列排序
list.sort ()
你可以按特定的函数来: list.sort( 函数 ), 只要这个函数接受 两参数, 并按特定规则返回1, 0, -1就可以. — 很方便吧? 但 会大大减慢运行速度. 下面的方法, 俺举例子来说明可能更容易 明白.

比方说你的数列是 l = ['az', 'by'], 你想以第二个字母来排序. 先取出你的关键词, 并与每个字串组成一个元组: new = map (lambda s: (s[1], s), l )

于是new变成[('z', 'az'), ('y', 'by')], 再把new排一下序: new.sort()

则new就变成 [('y', 'by'), ('z', 'az')], 再返回每个元组中 的第二个字串: sorted = map (lambda t: t[1], new)

于是sorted 就是: ['by', 'az']了. 这里的lambda与map用得很 好.

Python2.4以后, sort和sorted的使用可以参考这片 Wiki: HowToSort

1.1.4. 循环
比如for循环. 当循环体很简单时, 则循环的调用前头(overhead) 会显得很臃肿, 此时map又可以帮忙了. 比如你想把一个长数列 l=['a', 'b', ...]中的每个字串变成大写, 可能会用:

Toggle line numbers
1 import string
2 newL = []
3 for s in l: newL.append( string.upper(s) )
用map就可以省去for循环的前头:

Toggle line numbers
1 import string
2 newL = map (string.upper, l)
Guido的文章讲得很详细.

1.1.5. 局域变量 及 ‘.’
象上面, 若用 append = newL.append, 及换种import方法:

Toggle line numbers
1 import string
2 append = newL.append
3 for s in l: append (string.upper(s))
会比在for中运行newL.append快一些, 为啥? 局域变量容易寻找.

俺自己就不比较时间了, Skip Montanaro的结果是:

基本循环: 3.47秒
去点用局域变量: 1.79秒
使用map: 0.54秒

1.1.6. try的使用
比如你想计算一个字串数列: l = ['I', 'You', '<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>', 'Perl', ...] 中每个词出现的次数, 你可能会:

Toggle line numbers
1 count = {}
2 for s in l:
3     if not count.has_key(s): count[s] = 0
4     else: count[s] += 1
由于每次都得在count中寻找是否已有同名关键词, 会很费时间. 而用try:

Toggle line numbers
1 count ={}
2 for s in l:
3     try: count[s] += 1
4     except KeyError: count[s] = 0
就好得多. 当然若经常出现例外时, 就不要用try了.

1.1.7. import语句
这好理解. 就是避免在函数定义中来import一个模块, 应全在 全局块中来import

1.1.8. 大量数据处理
由于<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>中的函数调用前头(overhead)比较重, 所以处理大量 数据时, 应:

Toggle line numbers
1 def f():
2 for d in hugeData: …
3 f()
而不要:

Toggle line numbers
1 def f(d): …
2 for d in hugeData: f(d)
这点好象对其它语言也适用, 差不多是放之四海而皆准, 不过对 解释性语言就更重要了.

1.1.9. 减少周期性检查
这是<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>的本征功能: 周期性检查有没有其它绪(thread)或系 统信号(signal)等要处理.

可以用sys模块中的setcheckinterval 来设置每次检查的时间间隔.

缺省是10, 即每10个虚拟指令 (virtual instruction)检查一次.

当你不用绪并且也懒得搭理 系统信号时, 将检查周期设长会增加速度, 有时还会很显著.

—编/译完毕. 看来<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>是易学难精了, 象围棋?

2. 我们自个儿的体悟
请有心得者分享!

在“大量数据处理”小节里，是不是说，不要再循环体内部调用函数，应该把函数放到外面？从Python2.2开始,”找出速度瓶颈”,已经可以使用hotshot模块了.据说对程序运行效率的影响要比profile小. — jacobfan
“由于<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>中的函数调用前头(overhead)比较重, 所以处理大量 数据时, 应: ” 这句译文中,overhead翻译成”前头”好象不妥.翻译成”由于<a title="Posts tagged with python" href="http://www.donevii.com/post/tag/python" rel="tag">Python</a>中函数调用的开销比较大,…”要好些 — jacobfan
数组排序中讲的方法真的会快点吗? 真的快到我们值得放弃直接用sort得到得可读性吗?值得怀疑 — hoxide
Python2.4以后 sort和sorted的使用更加灵活，link已经加到文中，我没有比较过效率。-yichun
关于 “try的使用”：
其实setdefault方法就是为这个目的设的：

Toggle line numbers
1 count = {}
2 for s in l:
3     count.setdefault(s, 0) += 1
这个其实能做更多。通常遇到的问题是要把类似的东西group起来，所以你可能想用：

Toggle line numbers
1 count = {}
2 for s in l:
3     count.setdefault(s, []).append(s)
但是这样你只能把同样的东西hash起来，而不是一类东西。比如说你有一个dict构成的list叫sequence，需要按这些dict的某个key value分类，你还要对分类后的每个类别里面的这些dict各作一定的操作，你就需要用到Raymond实现的这个groupby，你就可以写:

totals = dict((key, group)
for key, group in groupby(sequence, lambda x: x.get(’Age’)))
<blockquote>看着不错，转载来得</blockquote>]]></description>
		<wfw:commentRss>http://www.ljhblog.com/python-efficiency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python这货果然不是编程语言，这是艺术</title>
		<link>http://www.ljhblog.com/python-art/</link>
		<comments>http://www.ljhblog.com/python-art/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 17:24:29 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=173</guid>
		<description><![CDATA[<blockquote>网上看到的一篇文章，挺有意思的...</blockquote>
看到 生成树表达式 一章，我几乎惊呼出来，这货果然是艺术。

若说C是大气滂泊的“九阳神功”，那Python就是优雅潇洒的“独孤九剑”。

OK，看看一步步缩减，步入精深的代码吧：

&#160;

程序实现寻找文件中的最长行。

&#160;

First：

<a href="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/cd7e103f510fd77370cf6cda.png"><img class="alignleft size-full wp-image-176" title="1" src="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/cd7e103f510fd77370cf6cda.png" alt="" width="355" height="225" /></a>

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

这是一板一眼的代码行，先是打开文件，对比行的长度判断，最后返回最长行。

&#160;

next：

<a href="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/f36afe8e08fb16b4513d92b4.png"><img class="alignleft size-full wp-image-177" title="2" src="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/f36afe8e08fb16b4513d92b4.png" alt="" width="309" height="196" /></a>

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

对程序操作的内存进行优化，打开文件，将文件内容存储到临时字符串，关闭对文件的操作，优化了内存。

&#160;

next；

<a href="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/0eb80dd86dfe496211df9b82.png"><img class="alignleft size-full wp-image-178" title="3" src="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/0eb80dd86dfe496211df9b82.png" alt="" width="399" height="204" /></a>

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

&#160;

对代码进行优化，用for循环对得到数据前进行了strip()方法处理行内容。

&#160;

next:

<a href="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/2144bb2be47c2ad5023bf665.png"><img class="alignleft size-full wp-image-181" title="4" src="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/2144bb2be47c2ad5023bf665.png" alt="" width="382" height="121" /></a>

&#160;

&#160;

&#160;

&#160;

代码优化+内存优化，直接去除了readline()操作，因为文件本身就成为了自己的迭代器，就不需要readline()函数。

&#160;

next:

<img class="alignleft size-full wp-image-180" title="5" src="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/3d684e3e4f5665a255e72375.png" alt="" width="363" height="85" />

&#160;

&#160;

&#160;

代码+内存优化。用生成器表达式代替列表解析。

&#160;

next:

<a href="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/962cb9899c5d99daa5c2727e.png"><img class="alignleft size-full wp-image-182" title="6" src="http://www.ljhblog.com/wp/wp-content/uploads/2011/12/962cb9899c5d99daa5c2727e.png" alt="" width="452" height="52" /></a>

&#160;

&#160;

内存+代码优化，取消了打开文件的处理，直接读取调用文件，并用for循环和max()函数实现选取操作。

&#160;

Python实现了从9行代码简化到1行。而且其中编程的思路可谓精巧至极，乔某唯有望而生谈焉。

&#160;
<blockquote>原帖地址：http://hi.baidu.com/%C7%C73%C9%D9/blog/item/832d84f9e41ab41ed9f9fdb7.html</blockquote>]]></description>
		<wfw:commentRss>http://www.ljhblog.com/python-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python字符串的encode与decode研究心得乱码问题解决方法</title>
		<link>http://www.ljhblog.com/python-encode-decode/</link>
		<comments>http://www.ljhblog.com/python-encode-decode/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 12:45:16 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=168</guid>
		<description><![CDATA[<div id="art_demo">为什么Python使用过程中会出现各式各样的乱码问题，明明是中文字符却显示成“\xe4\xb8\xad\xe6\x96\x87”的形式？</div>
<div></div>
<div id="con_all"></div>
<div id="art_content">

为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)”？本文就来研究一下这个问题。
<div>

<hr />

</div>
<div>字符串在Python内部的表示是unicode编码，因此，在做编码转换时，通常需要以unicode作为中间编码，即先将其他编码的字符串解码（decode）成unicode，再从unicode编码（encode）成另一种编码。</div>
decode的作用是将其他编码的字符串转换成unicode编码，如str1.decode('gb2312')，表示将gb2312编码的字符串str1转换成unicode编码。

encode的作用是将unicode编码转换成其他编码的字符串，如str2.encode('gb2312')，表示将unicode编码的字符串str2转换成gb2312编码。

因此，转码的时候一定要先搞明白，字符串str是什么编码，然后decode成unicode，然后再encode成其他编码

<hr />

代码中字符串的默认编码与代码文件本身的编码一致。

如：s='中文'

如果是在utf8的文件中，该字符串就是utf8编码，如果是在gb2312的文件中，则其编码为gb2312。这种情况下，要进行编码转换，都需要先用decode方法将其转换成unicode编码，再使用encode方法将其转换成其他编码。通常，在没有指定特定的编码方式时，都是使用的系统默认编码创建的代码文件。

如果字符串是这样定义：s=u'中文'

则该字符串的编码就被指定为unicode了，即python的内部编码，而与代码文件本身的编码无关。因此，对于这种情况做编码转换，只需要直接使用encode方法将其转换成指定编码即可。

<hr />

如果一个字符串已经是unicode了，再进行解码则将出错，因此通常要对其编码方式是否为unicode进行判断：

isinstance(s, unicode) #用来判断是否为unicode

用非unicode编码形式的str来encode会报错

<hr />

如何获得系统的默认编码？

#!/usr/bin/env python
#coding=utf-8
import sys
print sys.getdefaultencoding()

该段程序在英文<a href="http://www.jb51.net/list/list_88_1.htm" target="_blank"><span style="color: red;">WindowsXP</span></a>上输出为：ascii

<hr />

在某些IDE中，字符串的输出总是出现乱码，甚至错误，其实是由于IDE的结果输出控制台自身不能显示字符串的编码，而不是程序本身的问题。

如在UliPad中运行如下代码：

s=u"中文"
print s

会提示：UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)。这是因为UliPad在英文<a href="http://www.jb51.net/list/list_88_1.htm" target="_blank"><span style="color: red;">WindowsXP</span></a>上的控制台信息输出窗口是按照ascii编码输出的（英文系统的默认编码是ascii），而上面代码中的字符串是Unicode编码的，所以输出时产生了错误。

将最后一句改为：print s.encode('gb2312')

则能正确输出“中文”两个字。

若最后一句改为：print s.encode('utf8')

则输出：\xe4\xb8\xad\xe6\x96\x87，这是控制台信息输出窗口按照ascii编码输出utf8编码的字符串的结果。

<hr />

unicode(str,'gb2312')与str.decode('gb2312')是一样的，都是将gb2312编码的str转为unicode编码

使用str.__class__可以查看str的编码形式

<hr />

原理说了半天，最后来个包治百病的吧：）
<div>代码如下:</div>
<div id="code64199">
#!/usr/bin/env python
#coding=utf-8
s="中文"

if isinstance(s, unicode):
#s=u"中文"
print s.encode('gb2312')
else:
#s="中文"
print s.decode('utf-8').encode('gb2312')</div>
</div>]]></description>
		<wfw:commentRss>http://www.ljhblog.com/python-encode-decode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python程序员的进化</title>
		<link>http://www.ljhblog.com/python-programmer-evolution/</link>
		<comments>http://www.ljhblog.com/python-programmer-evolution/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 11:13:55 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=152</guid>
		<description><![CDATA[以前本博客发布过一篇《<a href="http://www.ljhblog.com/evolution-programmer/" target="_blank">程序员的进化</a>》，以一种幽默的代码展现方式调侃了程序。下面这篇是关于Python程序员的。以阶乘为例，很有意思。
<h4>新手程序员</h4>
<div>
<div id="highlighter_255410">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div></td>
<td>
<div>
<div><code>def</code> <code>factorial(x):</code></div>
<div><code>    </code><code>if</code> <code>x </code><code>=</code><code>=</code> <code>0</code><code>:</code></div>
<div><code>        </code><code>return</code> <code>1</code></div>
<div><code>    </code><code>else</code><code>:</code></div>
<div><code>        </code><code>return</code> <code>x </code><code>*</code> <code>factorial(x </code><code>-</code> <code>1</code><code>)</code></div>
<div><code>print</code> <code>factorial(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>第一年的刚学完Pascal的新手</h4>
<div>
<div id="highlighter_56947">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div></td>
<td>
<div>
<div><code>def</code> <code>factorial(x):</code></div>
<div><code>    </code><code>result </code><code>=</code> <code>1</code></div>
<div><code>    </code><code>i </code><code>=</code> <code>2</code></div>
<div><code>    </code><code>while</code> <code>i &#60;</code><code>=</code> <code>x:</code></div>
<div><code>        </code><code>result </code><code>=</code> <code>result </code><code>*</code> <code>i</code></div>
<div><code>        </code><code>i </code><code>=</code> <code>i </code><code>+</code> <code>1</code></div>
<div><code>    </code><code>return</code> <code>result</code></div>
<div><code>print</code> <code>factorial(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4></h4>
<h4>第一年的刚学完C语言的新手</h4>
<div>
<div id="highlighter_223616">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div></td>
<td>
<div>
<div><code>def</code> <code>fact(x): </code><code>#{</code></div>
<div><code>    </code><code>result </code><code>=</code> <code>i </code><code>=</code> <code>1</code><code>;</code></div>
<div><code>    </code><code>while</code> <code>(i &#60;</code><code>=</code> <code>x): </code><code>#{</code></div>
<div><code>        </code><code>result </code><code>*</code><code>=</code> <code>i;</code></div>
<div><code>        </code><code>i </code><code>+</code><code>=</code> <code>1</code><code>;</code></div>
<div><code>    </code><code>#}</code></div>
<div><code>    </code><code>return</code> <code>result;</code></div>
<div><code>#}</code></div>
<div><code>print</code><code>(fact(</code><code>6</code><code>))</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>第一年刚学完SICP的新手</h4>
<div>
<div id="highlighter_552076">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div></td>
<td>
<div>
<div><code>@tailcall</code></div>
<div><code>def</code> <code>fact(x, acc</code><code>=</code><code>1</code><code>):</code></div>
<div><code>    </code><code>if</code> <code>(x &#62; </code><code>1</code><code>): </code><code>return</code> <code>(fact((x </code><code>-</code> <code>1</code><code>), (acc </code><code>*</code> <code>x)))</code></div>
<div><code>    </code><code>else</code><code>:       </code><code>return</code> <code>acc</code></div>
<div><code>print</code><code>(fact(</code><code>6</code><code>))</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>第一年刚学完Python的新手</h4>
<div>
<div id="highlighter_618468">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div></td>
<td>
<div>
<div><code>def</code> <code>Factorial(x):</code></div>
<div><code>    </code><code>res </code><code>=</code> <code>1</code></div>
<div><code>    </code><code>for</code> <code>i </code><code>in</code> <code>xrange</code><code>(</code><code>2</code><code>, x </code><code>+</code> <code>1</code><code>):</code></div>
<div><code>        </code><code>res </code><code>*</code><code>=</code> <code>i</code></div>
<div><code>    </code><code>return</code> <code>res</code></div>
<div><code>print</code> <code>Factorial(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>爱偷懒的程序员</h4>
<div>
<div id="highlighter_315028">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div></td>
<td>
<div>
<div><code>def</code> <code>fact(x):</code></div>
<div><code>    </code><code>return</code> <code>x &#62; </code><code>1</code> <code>and</code> <code>x </code><code>*</code> <code>fact(x </code><code>-</code> <code>1</code><code>) </code><code>or</code> <code>1</code></div>
<div><code>print</code> <code>fact(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>更懒的 Python 程序员</h4>
<div>
<div id="highlighter_195291">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div></td>
<td>
<div>
<div><code>f </code><code>=</code> <code>lambda</code> <code>x: x </code><code>and</code> <code>x </code><code>*</code> <code>f(x </code><code>-</code> <code>1</code><code>) </code><code>or</code> <code>1</code></div>
<div><code>print</code> <code>f(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>Python 专家</h4>
<div>
<div id="highlighter_405809">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div></td>
<td>
<div>
<div><code>import</code> <code>operator as op</code></div>
<div><code>import</code> <code>functional as f</code></div>
<div><code>fact </code><code>=</code> <code>lambda</code> <code>x: f.foldl(op.mul, </code><code>1</code><code>, </code><code>xrange</code><code>(</code><code>2</code><code>, x </code><code>+</code> <code>1</code><code>))</code></div>
<div><code>print</code> <code>fact(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>Python 黑客</h4>
<div>
<div id="highlighter_567168">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div></td>
<td>
<div>
<div><code>import</code> <code>sys</code></div>
<div><code>@tailcall</code></div>
<div><code>def</code> <code>fact(x, acc</code><code>=</code><code>1</code><code>):</code></div>
<div><code>    </code><code>if</code> <code>x: </code><code>return</code> <code>fact(x.__sub__(</code><code>1</code><code>), acc.__mul__(x))</code></div>
<div><code>    </code><code>return</code> <code>acc</code></div>
<div><code>sys.stdout.write(</code><code>str</code><code>(fact(</code><code>6</code><code>)) </code><code>+</code> <code>'\n'</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>专家级程序员</h4>
<div>
<div id="highlighter_216916">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div></td>
<td>
<div>
<div><code>import</code> <code>c_math</code></div>
<div><code>fact </code><code>=</code> <code>c_math.fact</code></div>
<div><code>print</code> <code>fact(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>英语系的专家级程序员</h4>
<div>
<div id="highlighter_708922">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div></td>
<td>
<div>
<div><code>import</code> <code>c_maths</code></div>
<div><code>fact </code><code>=</code> <code>c_maths.fact</code></div>
<div><code>print</code> <code>fact(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>Web 设计者</h4>
<div>
<div id="highlighter_368140">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div></td>
<td>
<div>
<div><code>def</code> <code>factorial(x):</code></div>
<div><code>    </code><code>#-------------------------------------------------</code></div>
<div><code>    </code><code>#--- Code snippet from The Math Vault          ---</code></div>
<div><code>    </code><code>#--- Calculate factorial (C) Arthur Smith 1999 ---</code></div>
<div><code>    </code><code>#-------------------------------------------------</code></div>
<div><code>    </code><code>result </code><code>=</code> <code>str</code><code>(</code><code>1</code><code>)</code></div>
<div><code>    </code><code>i </code><code>=</code> <code>1</code> <code>#Thanks Adam</code></div>
<div><code>    </code><code>while</code> <code>i &#60;</code><code>=</code> <code>x:</code></div>
<div><code>        </code><code>#result = result * i  #It's faster to use *=</code></div>
<div><code>        </code><code>#result = str(result * result + i)</code></div>
<div><code>           </code><code>#result = int(result *= i) #??????</code></div>
<div><code>        </code><code>result </code><code>str</code><code>(</code><code>int</code><code>(result) </code><code>*</code> <code>i)</code></div>
<div><code>        </code><code>#result = int(str(result) * i)</code></div>
<div><code>        </code><code>i </code><code>=</code> <code>i </code><code>+</code> <code>1</code></div>
<div><code>    </code><code>return</code> <code>result</code></div>
<div><code>print</code> <code>factorial(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>Unix 程序员</h4>
<div>
<div id="highlighter_782253">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div></td>
<td>
<div>
<div><code>import</code> <code>os</code></div>
<div><code>def</code> <code>fact(x):</code></div>
<div><code>    </code><code>os.system(</code><code>'factorial '</code> <code>+</code> <code>str</code><code>(x))</code></div>
<div><code>fact(</code><code>6</code><code>)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>Windows 程序员</h4>
<div>
<div id="highlighter_769537">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
<div>18</div></td>
<td>
<div>
<div><code>NULL </code><code>=</code> <code>None</code></div>
<div><code>def</code> <code>CalculateAndPrintFactorialEx(dwNumber,</code></div>
<div><code>                                 </code><code>hOutputDevice,</code></div>
<div><code>                                 </code><code>lpLparam,</code></div>
<div><code>                                 </code><code>lpWparam,</code></div>
<div><code>                                 </code><code>lpsscSecurity,</code></div>
<div><code>                                 </code><code>*</code><code>dwReserved):</code></div>
<div><code>    </code><code>if</code> <code>lpsscSecurity !</code><code>=</code> <code>NULL:</code></div>
<div><code>        </code><code>return</code> <code>NULL </code><code>#Not implemented</code></div>
<div><code>    </code><code>dwResult </code><code>=</code> <code>dwCounter </code><code>=</code> <code>1</code></div>
<div><code>    </code><code>while</code> <code>dwCounter &#60;</code><code>=</code> <code>dwNumber:</code></div>
<div><code>        </code><code>dwResult </code><code>*</code><code>=</code> <code>dwCounter</code></div>
<div><code>        </code><code>dwCounter </code><code>+</code><code>=</code> <code>1</code></div>
<div><code>    </code><code>hOutputDevice.write(</code><code>str</code><code>(dwResult))</code></div>
<div><code>    </code><code>hOutputDevice.write(</code><code>'\n'</code><code>)</code></div>
<div><code>    </code><code>return</code> <code>1</code></div>
<div><code>import</code> <code>sys</code></div>
<div><code>CalculateAndPrintFactorialEx(</code><code>6</code><code>, sys.stdout, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
<h4>公司里的程序员</h4>
<div>
<div id="highlighter_415630">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
<div>18</div>
<div>19</div>
<div>20</div>
<div>21</div>
<div>22</div>
<div>23</div>
<div>24</div>
<div>25</div>
<div>26</div>
<div>27</div>
<div>28</div>
<div>29</div>
<div>30</div>
<div>31</div>
<div>32</div>
<div>33</div>
<div>34</div>
<div>35</div>
<div>36</div>
<div>37</div>
<div>38</div>
<div>39</div>
<div>40</div>
<div>41</div>
<div>42</div>
<div>43</div>
<div>44</div></td>
<td>
<div>
<div><code>def</code> <code>new(</code><code>cls</code><code>, </code><code>*</code><code>args, </code><code>*</code><code>*</code><code>kwargs):</code></div>
<div><code>    </code><code>return</code> <code>cls</code><code>(</code><code>*</code><code>args, </code><code>*</code><code>*</code><code>kwargs)</code></div>
<div><code>class</code> <code>Number(</code><code>object</code><code>):</code></div>
<div><code>    </code><code>pass</code></div>
<div><code>class</code> <code>IntegralNumber(</code><code>int</code><code>, Number):</code></div>
<div><code>    </code><code>def</code> <code>toInt(</code><code>self</code><code>):</code></div>
<div><code>        </code><code>return</code> <code>new (</code><code>int</code><code>, </code><code>self</code><code>)</code></div>
<div><code>class</code> <code>InternalBase(</code><code>object</code><code>):</code></div>
<div><code>    </code><code>def</code> <code>__init__(</code><code>self</code><code>, base):</code></div>
<div><code>        </code><code>self</code><code>.base </code><code>=</code> <code>base.toInt()</code></div>
<div><code>    </code><code>def</code> <code>getBase(</code><code>self</code><code>):</code></div>
<div><code>        </code><code>return</code> <code>new (IntegralNumber, </code><code>self</code><code>.base)</code></div>
<div><code>class</code> <code>MathematicsSystem(</code><code>object</code><code>):</code></div>
<div><code>    </code><code>def</code> <code>__init__(</code><code>self</code><code>, ibase):</code></div>
<div><code>        </code><code>Abstract</code></div>
<div><code>    </code><code>@</code><code>classmethod</code></div>
<div><code>    </code><code>def</code> <code>getInstance(</code><code>cls</code><code>, ibase):</code></div>
<div><code>        </code><code>try</code><code>:</code></div>
<div><code>            </code><code>cls</code><code>.__instance</code></div>
<div><code>        </code><code>except</code> <code>AttributeError:</code></div>
<div><code>            </code><code>cls</code><code>.__instance </code><code>=</code> <code>new (</code><code>cls</code><code>, ibase)</code></div>
<div><code>        </code><code>return</code> <code>cls</code><code>.__instance</code></div>
<div><code>class</code> <code>StandardMathematicsSystem(MathematicsSystem):</code></div>
<div><code>    </code><code>def</code> <code>__init__(</code><code>self</code><code>, ibase):</code></div>
<div><code>        </code><code>if</code> <code>ibase.getBase() !</code><code>=</code> <code>new (IntegralNumber, </code><code>2</code><code>):</code></div>
<div><code>            </code><code>raise</code> <code>NotImplementedError</code></div>
<div><code>        </code><code>self</code><code>.base </code><code>=</code> <code>ibase.getBase()</code></div>
<div><code>    </code><code>def</code> <code>calculateFactorial(</code><code>self</code><code>, target):</code></div>
<div><code>        </code><code>result </code><code>=</code> <code>new (IntegralNumber, </code><code>1</code><code>)</code></div>
<div><code>        </code><code>i </code><code>=</code> <code>new (IntegralNumber, </code><code>2</code><code>)</code></div>
<div><code>        </code><code>while</code> <code>i &#60;</code><code>=</code> <code>target:</code></div>
<div><code>            </code><code>result </code><code>=</code> <code>result </code><code>*</code> <code>i</code></div>
<div><code>            </code><code>i </code><code>=</code> <code>i </code><code>+</code> <code>new (IntegralNumber, </code><code>1</code><code>)</code></div>
<div><code>        </code><code>return</code> <code>result</code></div>
<div><code>print</code> <code>StandardMathematicsSystem.getInstance(new (InternalBase, new (IntegralNumber, </code><code>2</code><code>))).calculateFactorial(new (IntegralNumber, </code><code>6</code><code>))</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>]]></description>
		<wfw:commentRss>http://www.ljhblog.com/python-programmer-evolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>程序员的进化</title>
		<link>http://www.ljhblog.com/evolution-programmer/</link>
		<comments>http://www.ljhblog.com/evolution-programmer/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 11:10:49 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=147</guid>
		<description><![CDATA[如果把程序员分级，那么就是：

<strong>高中时期</strong>
<blockquote>
<pre>  10 PRINT "HELLO WORLD"
  20 END</pre>
</blockquote>
<strong>大学新生</strong>
<blockquote>
<pre>  program Hello(input, output)
    begin
      writeln(\'Hello World\')
    end.</pre>
</blockquote>
<strong>高年级大学生</strong>
<blockquote>
<pre>#include 

int main(void)
{
   printf("Hello, world!\\n");
   return 0;
}</pre>
</blockquote>
<strong>职业新手</strong>
<blockquote>
<pre>  #include
  void main(void)
  {
    char *message[] = {"Hello ", "World"};
    int i;

    for(i = 0; i &#60; 2; ++i)
      printf("%s", message[i]);
    printf("\\n");
  }</pre>
</blockquote>
职业老手
<blockquote>
<pre>  #include
  #include
 using namespace std;

  class string
  {
  private:
    int size;
    char *ptr;

  string() : size(0), ptr(new char[1]) { ptr[0] = 0; }

    string(const string &#38;s) : size(s.size)
    {
      ptr = new char[size + 1];
      strcpy(ptr, s.ptr);
    }

    ~string()
    {
      delete [] ptr;
    }

    friend ostream &#38;operator &#60;&#60;(ostream &#38;, const string &#38;);
    string &#38;operator=(const char *);
  };

  ostream &#38;operator&#60;&#60;(ostream &#38;stream, const string &#38;s)
  {
    return(stream &#60;&#60; s.ptr);
  }

  string &#38;string::operator=(const char *chrs)
  {
    if (this != &#38;chrs)
    {
      delete [] ptr;
     size = strlen(chrs);
      ptr = new char[size + 1];
      strcpy(ptr, chrs);
    }
    return(*this);
  }

  int main()
  {
    string str;

    str = "Hello World";
    cout &#60;&#60; str &#60;&#60; endl;

    return(0);
  }</pre>
</blockquote>
<strong>大师级</strong>
<blockquote>
<pre>  [
  uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
  ]
  library LHello
  {
      // bring in the master library
      importlib("actimp.tlb");
      importlib("actexp.tlb");

      // bring in my interfaces
      #include "pshlo.idl"

      [
      uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
      ]
      cotype THello
   {
   interface IHello;
   interface IPersistFile;
   };
  };

  [
  exe,
  uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
  ]
  module CHelloLib
  {

      // some code related header files
      importheader();
      importheader(
);
      importheader();
      importheader("pshlo.h");
      importheader("shlo.hxx");
      importheader("mycls.hxx");

      // needed typelibs
      importlib("actimp.tlb");
      importlib("actexp.tlb");
      importlib("thlo.tlb");

      [
      uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
      aggregatable
      ]
      coclass CHello
   {
   cotype THello;
   };
  };

  #include "ipfix.hxx"

  extern HANDLE hEvent;

  class CHello : public CHelloBase
  {
  public:
      IPFIX(CLSID_CHello);

      CHello(IUnknown *pUnk);
      ~CHello();

      HRESULT  __stdcall PrintSz(LPWSTR pwszString);

  private:
      static int cObjRef;
  };

  #include
  #include

  #include
  #include
  #include "thlo.h"
  #include "pshlo.h"
  #include "shlo.hxx"
  #include "mycls.hxx"

  int CHello::cObjRef = 0;

  CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
  {
      cObjRef++;
      return;
  }

  HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)
  {
      printf("%ws
", pwszString);
      return(ResultFromScode(S_OK));
  }

  CHello::~CHello(void)
  {

  // when the object count goes to zero, stop the server
  cObjRef--;
  if( cObjRef == 0 )
      PulseEvent(hEvent);

  return;
  }

  #include
  #include

  #include "pshlo.h"
  #include "shlo.hxx"
  #include "mycls.hxx"

  HANDLE hEvent;

   int _cdecl main(
  int argc,
  char * argv[]
  ) {
  ULONG ulRef;
  DWORD dwRegistration;
  CHelloCF *pCF = new CHelloCF();

  hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

  // Initialize the OLE libraries
  CoInitializeEx(NULL, COINIT_MULTITHREADED);

  CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
      REGCLS_MULTIPLEUSE, &#38;dwRegistration);

  // wait on an event to stop
  WaitForSingleObject(hEvent, INFINITE);

  // revoke and release the class object
  CoRevokeClassObject(dwRegistration);
  ulRef = pCF-&#62;Release();

  // Tell OLE we are going away.
  CoUninitialize();

  return(0); }

  extern CLSID CLSID_CHello;
  extern UUID LIBID_CHelloLib;

  CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
      0x2573F891,
      0xCFEE,
      0x101A,
      { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  };

  UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
      0x2573F890,
      0xCFEE,
      0x101A,
      { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  };

  #include
  #include

  #include
  #include
  #include
  #include "pshlo.h"
  #include "shlo.hxx"
  #include "clsid.h"

  int _cdecl main(
  int argc,
  char * argv[]
  ) {
  HRESULT  hRslt;
  IHello        *pHello;
  ULONG  ulCnt;
  IMoniker * pmk;
  WCHAR  wcsT[_MAX_PATH];
  WCHAR  wcsPath[2 * _MAX_PATH];

  // get object path
  wcsPath[0] = \'\\0\';
  wcsT[0] = \'\\0\';
  if( argc &#62; 1) {
      mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
      wcsupr(wcsPath);
      }
  else {
      fprintf(stderr, "Object path must be specified\\n");
      return(1);
      }

  // get print string
  if(argc &#62; 2)
      mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
  else
      wcscpy(wcsT, L"Hello World");

  printf("Linking to object %ws\\n", wcsPath);
  printf("Text String %ws\\n", wcsT);

  // Initialize the OLE libraries
  hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

  if(SUCCEEDED(hRslt)) {

      hRslt = CreateFileMoniker(wcsPath, &#38;pmk);
      if(SUCCEEDED(hRslt))
   hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&#38;pHello);

      if(SUCCEEDED(hRslt)) {

   // print a string out
   pHello-&#62;PrintSz(wcsT);

   Sleep(2000);
   ulCnt = pHello-&#62;Release();
   }
      else
   printf("Failure to connect, status: %lx", hRslt);

      // Tell OLE we are going away.
      CoUninitialize();
      }

  return(0);
  }</pre>
</blockquote>
<strong>黑客学徒</strong>
<blockquote>
<pre>  #!/usr/local/bin/perl
  $msg="Hello, world.\\n";
  if ($#ARGV &#62;= 0) {
    while(defined($arg=shift(@ARGV))) {
      $outfilename = $arg;
      open(FILE, "&#62;" . $outfilename) &#124;&#124; die "Can\'t write $arg: $!\\n";
      print (FILE $msg);
      close(FILE) &#124;&#124; die "Can\'t close $arg: $!\\n";
    }
  } else {
    print ($msg);
  }
  1;</pre>
</blockquote>
<strong>有经验的黑客</strong>
<blockquote>
<pre>  #include
  #define S "Hello, World\\n"
  main(){exit(printf(S) == strlen(S) ? 0 : 1);}</pre>
</blockquote>
<strong>老练的黑客</strong>
<blockquote>
<pre>  % cc -o a.out ~/src/misc/hw/hw.c
  % a.out</pre>
</blockquote>
<strong>超级黑客</strong>
<blockquote>
<pre>  % echo "Hello, world."</pre>
</blockquote>
<strong>一线经理</strong>
<blockquote>
<pre>  10 PRINT "HELLO WORLD"
  20 END</pre>
</blockquote>
<strong>中层经理</strong>
<blockquote>
<pre>  mail -s "Hello, world." bob@b12
  Bob, could you please write me a program that prints "Hello, world."?
  I need it by tomorrow.
  ^D</pre>
</blockquote>
<strong>高级经理</strong>
<blockquote>
<pre>  % zmail jim
  I need a "Hello, world." program by this afternoon.</pre>
</blockquote>
<strong>首席执行官</strong>
<blockquote>
<pre>  % letter
  letter: Command not found.
  % mail
  To: ^X ^F ^C
  % help mail
  help: Command not found.
  % damn!
  !: Event unrecognized
  % logout</pre>
</blockquote>]]></description>
		<wfw:commentRss>http://www.ljhblog.com/evolution-programmer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World 大集合</title>
		<link>http://www.ljhblog.com/large-collection-of-hello-world/</link>
		<comments>http://www.ljhblog.com/large-collection-of-hello-world/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 11:03:13 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=143</guid>
		<description><![CDATA[编程的人应该都知道什么是Hello World。这是一个最简单的程序，其只在屏幕上输出“Hello World”字样，这通常是初学者的在学习编程时的第一个示例。把打印出 “Hello World” 作为第一个范例程序，现在已经成为编程语言学习的传统。

“Hello World”起源于Brian Kernighan 和Dennis MacAlistair Ritchie写的计算机程序设计教程《C语言程序设计》（<a title="en:The C Programming Language" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/The_C_Programming_Language?referer=http%3A%2F%2Fcoolshell.cn%2Ffeatured_posts');" href="http://en.wikipedia.org/wiki/The_C_Programming_Language"><em>The C Programming Language</em></a>）而广泛流传；但这本书并不是 “hello, world” 的滥觞，虽然这是一个普遍存在的错误认知。

这范例程序最早出现于 1972 年，由贝尔实验室成员 Brian Kernighan 撰写的内部技术文件《Introduction to the Language B》之中。不久同作者于 1974 年所撰写的《Programming in C: A Tutorial》，也延用这个范例；而以本文件扩编改写的《C语言程序设计》也保留了这个範例程式。

“hello, world” 程序的标准打印内容必须满足“全小写，无惊叹号，逗点后需空一格”，不过流传至今，完全恪守传统的反而罕见。

现在就来看看最全的Hello World集合:

<a onclick="pageTracker._trackPageview('/outgoing/www.roesler-ac.de/wolfram/hello.htm?referer=http%3A%2F%2Fcoolshell.cn%2Ffeatured_posts');" href="http://www.roesler-ac.de/wolfram/hello.htm"><strong>http://www.roesler-ac.de/wolfram/hello.htm</strong></a>

这个网站很BT啊，其开始是从1994年10月3日，于1999年12月30日上互联网，2005年7月14日收集到了超过200个不同语言的Hello World，2006年12月6日达到300个，2008年2月27日达到400个。

今天这个网站有一共421个不同语言的Hello World，其中有63个来自人类的语言。]]></description>
		<wfw:commentRss>http://www.ljhblog.com/large-collection-of-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>S60V3 Python 教程 (修复下载错误)</title>
		<link>http://www.ljhblog.com/s60v3-python-tutorial/</link>
		<comments>http://www.ljhblog.com/s60v3-python-tutorial/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 13:01:42 +0000</pubDate>
		<dc:creator>L-JH</dc:creator>
				<category><![CDATA[编程计算机手机]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[s60v3]]></category>
		<category><![CDATA[教程]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.ljhblog.com/?p=106</guid>
		<description><![CDATA[前些日子有不少机友问我是怎么学的，其实就是自学，摸索出来的

也有不少机友问我要教程，最近我把整理出来了

感兴趣的可以学学，自己编写点小软件玩玩。编程序挺有意思的，我喜欢那过程与结果

这些教程为Symbian(塞班)S60V3Python的教程。写的程序只在Symbian(塞班)  Python平台上能运行，但不能保证各个平台的兼容。当然，Python语言的根本没变，你学了后，就能在其他系统上的Python平台写些东西了，例如Windous系统上的Python平台，关于这个，以后我会发文章帖出些小脚本，关注本博客啦(订阅本博客获取最新动态)

教程下载(下载后改后缀为zip)：
注：下载出错：1.请用其他浏览器尝试 2.设置UC的缩放为适应屏幕 3.关闭或打开WAP压缩中转

[download id="8"] 哇麦论坛系列的

[download id="9"] 米饭系列的，里面分doc文档与txt带源码带图片两种

[download id="10"] 其他人的

[download id="11"] 杂七杂八的单章教程

[download id="12"] 上面这些教程带的编程、教学用到的软件与工具，单独提出来打包

[download id="13"] 我手机里的一些编程软件及工具，其实很多都不常用

[download id="14"] 最后是收集的一大堆实用、实例、示例脚本

-----------------------------------
上传了我几次，大半天 -_-!

如果你能把上面前三个看完，写个S60V3小程序不成问题了]]></description>
		<wfw:commentRss>http://www.ljhblog.com/s60v3-python-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

