![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python语言
末世凡鸟
这个作者很懒,什么都没留下…
展开
-
Python装饰器入门详解
Python中的装饰器是你进入Python大门的一道坎,不管你跨不跨过去它都在那里。 为什么需要装饰器 我们假设你的程序实现了say_hello()和say_goodbye()两个函数。 def say_hello(): print "hello!" def say_goodbye(): print "hello!" # bug here if __转载 2017-08-08 10:28:04 · 394 阅读 · 0 评论 -
python字典
字典方法 跟前面所讲述的其它数据类型类似,字典也有一些方法。通过这些方法,能够实现对字典类型数据的操作。这回可不是屠龙之技的。这些方法在编程实践中经常会用到。 copy 拷贝,这个汉语是copy的音译,标准的汉语翻译是“复制”。我还记得当初在学DOS的时候,那个老师说“拷贝”,搞得我晕头转向,他没有说英文的“copy”发音,而是用标准汉语说“kao(三声)bei(四声)”,对于一原创 2017-07-31 11:46:16 · 284 阅读 · 0 评论 -
python列表list
反转 这个功能作为一个独立的项目提出来,是因为在编程中常常会用到。通过举例来说明反转的方法: >>> alst = [1,2,3,4,5,6] >>> alst[::-1] #反转 [6, 5, 4, 3, 2, 1] >>> alst [1, 2, 3, 4, 5, 6] 当然,对于字符串也可以 >>> lang 'python' >>> lang[::-1] 'noht原创 2017-07-31 10:53:03 · 453 阅读 · 0 评论 -
Python字符串操作
格式化 >>> print "Suzhou is more than %d years. %s lives in here." % (2500, "qiwsir") Suzhou is more than 2500 years. qiwsir lives in here. 对于浮点数字的打印输出,还可以限定输出的小数位数和其它样式。 >>> print "Today's tem原创 2017-07-31 10:26:02 · 165 阅读 · 0 评论