python 笔记 for loop and extend, append
list.append(item)
list.extend(sequence)
http://docs.python.org/tutorial/datastructures.html
http://docs.python.org/library/functions.html 这几天看一下
python howto
恩。python documentation 确实很好很强大啊!
list.append(x)Add an item to the end of the list; equivalent to a[len(a):] = [x].a[len(a):] 是一个list,slice得到的一个list,相当于把这一段截取出来的list,要是等于一个list b,相当于在a的末尾添加了b,但是b整个是一个元素。>>> c.append([1,2,3])>>> c[1, 2, 3, 4, [1, 2, 3]]list.extend(L)Extend the list by appending all the items in the given list; equivalent to a[len(a):] = L.
添加L中的元素,延长a
For loop, for(i=0; i<n; i++) in python is for i in range(0, n)
对于步长为2,则 for i in range(0, n, 2): range 函数可以改变步长! 不用 i += 2, Mark一下。
for i in range(0,10,2):
print i
0
2
4
6
8
比如寻找素数的程序。那么,寻找是不是被整除的时候,除了2 之外,可以从3开始,步长为2的去搜索。直到[sqrt(prime_n)](就是int(sqrt(prime_n)), 高斯函数)为止。
相关文档:
import urllib2
import time
import socket
from datetime import datetime
from thread_pool import *
def main():
url_list = {"sina":"http://www.sina.com.cn",
"sohu":"http://www.sohu.com",
"yahoo":"http://www.yahoo.com",
"xiaonei":"http://www.x ......
对于个人版,使用了.NET,安装完企业版后,看了看目录,发现大量python脚本。dll中也有sqlite3.dll
C:\Program Files\China Mobile\Efetion目录下文件:
Addin
boost_python.dll
bz2.pyd
dbghelp.dll
EFetion.exe
EFetion.exe.manifest
EFWP.exe
EFXLiveUpdate.exe
EFXLiveUpdate.exe.manifest
Face
Help.chm
......
编译了一个windows下的python3连接Mysql的库
mypysql
版本是 0.5.1 ,根据官方的修改日志,这个版本修改了0.5中一个内存泄漏问题。
源代码和编译后的文件为:
http://211.147.215.55/down/mypysql-0.5.1-win.zip
mypysql的官方地址 https://sourceforge.net/projects/mypysql/
......
python的变参
*args和**dargs是Python的两个可
变参数,两者有所不同的是*args是个tuple,**dargs是个dict。
*args
和**dargs并用时,*args必须放在**dargs的前面。
例如:
def func(a,b, *c):
pass
函数func至少有两个参数变参数放在tuple c中
def func(*c): 或者 def func(**d ......
#from pp3e Chapter 9.3
#############################################################################
# popup three new window, with style
# destroy() kills one window, quit() kills all windows and app; top-level
# windows have title, icon, iconify/deiconify and protocol for wm events;
# there ......