
Python
文章平均质量分 50
iteye_12594
这个作者很懒,什么都没留下…
展开
-
Python定制输出(格式化输出)
如果定制输出有多项,可以使用元组,如果只有一项不用加括号。'''Created on 2011-11-1@author: Administrator'''if __name__ == '__main__': name = 'marry' age = 21 print("%s's age is %d" % (name,age))...原创 2011-11-01 11:10:27 · 255 阅读 · 0 评论 -
Python中的字典操作
'''Created on 2011-11-1@author: dudong0726python中所谓的字典其实就是java中的map,操作类似'''if __name__ == '__main__': ab = { 'Swaroop' : 'swaroopch@byteofpython.info', 'Larry' : '...原创 2011-11-01 11:23:25 · 169 阅读 · 0 评论 -
Python序列切片操作
'''Created on 2011-11-1列表、字符串、元组都成为序列,序列常用操作为分片@author: dudong0726'''if __name__ == '__main__': item = ('apple','orange','tomato','egg','peer') #元组 list = ['apple...原创 2011-11-01 15:45:01 · 221 阅读 · 0 评论 -
python模块和类在import上的区别
1、类属于模块的一部分。当我们要建立一个类时,通常我们新建一个py文件,例如新建立cn.py,这个cn便成为我们的模块。2、然后在cn里面建立自己的类: '''Created on 2011-11-1@author: dudong0726'''class Person: ''' classdocs ''' Count = 0...原创 2011-11-01 17:17:16 · 802 阅读 · 0 评论 -
Python的集成
'''Created on 2011-11-2cn.py@author: dudong0726'''from cn import Personclass Person(object): def __init__(self,name,sex,age): self.name = name self.sex = sex ...原创 2011-11-02 12:06:34 · 168 阅读 · 0 评论 -
Python split()的一点困惑
今天看到论坛关于字符串分割问题,见http://www.iteye.com/topic/1117302,看看别人的思路自己用python写了下,竟然报错,list index 越界。 '''Created on 2011-11-2@author:dudong0726'''if __name__ == '__main__': str="[Type=UPC-A...原创 2011-11-02 12:42:42 · 178 阅读 · 0 评论