Skip to main content

python的dictionary (字典)、tuple (元组元组) 和 list (列表)

Dictionary 字典
定义:d = {'key1':'value1', 'key2':'value2'}
访问:d['key']
修改:d['key1'] = 'value'
删除:del d['key']
清空:d.clear()

List 列表
定义:l = ['a','b','c']
访问:l[index],index为负,则从尾部开始取。l[-n]=l[len(l)-n]
修改:l[index] = value
分片:l[n:m]
添加:l.append(new_vlaue),l.insert(index, new_value),l.extend(['e','f'])
删除:l.remove(value),只删除首次出现的值。
   l.pop(),删除最后一个值,并返回。

Tuple 元组
定义:t = ('a', b, 1)
访问:t[index]
修改:t[index] = value
分片:t[n:m]
定长,不可添加,删除。

当然,这些介绍远远不够,建议看深入 Python :Dive Into Python 中文版

Comments

Popular posts from this blog

Google Notebook整合了Google 书签

FF上一直装有Google笔记本的插件,一直没有到一面上去看,今天无意点到。发现多了个叫“Unfiled”的记事本,记得自己并未建过这么个东西,进去一看才发现,其实就是我的Google书签: 并且右下角也多了“Labels”,且与我Google书签中的相同。 其实人家的右上角的“ New features! ”里说得很清楚: Integration with Google Bookmarks Notebook is now integrated with Google Bookmarks. Your bookmarks will show up as a special Unfiled notebook, making Google Notebook a single place to collect and organize interesting web pages. To publish and collaborate, just drag and drop bookmarks into notebooks.

调用Response.Redirect时出现ThreadAbortException

调用Response.Redirect("test.aspx")时出现ThreadAbortException异常,是因为在内部调用Response.End(),而Response.End() 方法终止页的执行,并将此执行切换到应用程序的事件管线中的Application_EndRequest 事件。不执行 Response.End 后面的代码。可以使用 Response.Redirect ("test.aspx", false); 来代替。 更多情况请参考 PRB:在使用 Response.End、Response.Redirect或Server.Transfer时出现ThreadAbortException 适用于.net framework 1.0 1.1