易截截图软件、单文件、免安装、纯绿色、仅160KB

Python入门的36个例子 之 19

源代码下载:下载地址在这里
# 023
# Tuple(元素组)是不可变的列表
tuple1 = (1, 2, 3)
print tuple1
tuple2 = (tuple1, 4, 5, 6) # 一个元素组可以作为另外一个元素组的元素
print tuple2 # 并且能够在存储的时候保持原始的逻辑关系
for ele in tuple2:
print ele
print '\n'
for ele in tuple2[0]:
print ele
print '\n'
# 元素组与格式化输出
age = 22
name = 'Ning'
print '%s is %d years old.' % (name, age)
print 'Hello, %s' % name # 一个元素的时候可以不用元素组

(1, 2, 3)
((1, 2, 3), 4, 5, 6)
(1, 2, 3)
4
5
6
1
2
3
Ning is 22 years old.
Hello, Ning


相关文档:

最简单的 python 多线程示例

import time,thread
def test(a,b):
for i in range(a,b):
       time.sleep(1)
       print i
def start():
thread.start_new_thread(test,(1,1001))
thread.start_new_thread(test,(1000,2001))
if __name__=='__main__':
start()
......

Python Ascii to bcd bcd to Ascii

在网上搜不到关于 Ascii 和 bcd互相转化的文章,于是自己写了一个,和大家分享下。
没有考虑到效率,能够优化的地方望大家提出
"""
    AscII字符转换为BCD字符
"""
def asc2bcd(inAsc, pad_L0_R1 = 0):
#全部转换为大写,为后面的转换提供方便
    inAsc = inAsc.upper()
 &nb ......

Python入门的36个例子——17 Return

# 017
def lifeIsAMirror():
string = raw_input()
if string == 'I love you!':
return 'I love you, too!'
elif string == 'Fuck you!':
return ''
else:
return
# end of def
string = lifeIsAMirror()
if len(string) == 0:
print 'You have nothing.'
else: ......

Python:FriendFeed的Tornado Web Server

代码很简单,不到5k行。但是思路挺好的,改成non-blocking了之后效率就是能提高不少,特别是考虑到现代的web app都需要和其他的
HTTP服务器通信,blocking的代价太大了。 Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. The FriendFeed application ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号