会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
党佳飞
博客园
首页
新随笔
联系
订阅
管理
2018年1月23日
多继承
摘要: class Base: def play(self): return 'this is Base'class A(Base): def play(self): return 'this is A'class B(Base): def play(self): return 'this is B'cla
阅读全文
posted @ 2018-01-23 16:21 党佳飞
阅读(113)
评论(0)
推荐(0)
2018年1月18日
字符串和元组的方法
摘要: 字符串的方法: str = 'abcdabc' str.count('a') 返回元素 'a' 在字符串里面出现的次数 str.index('a') 返回元素的索引 str.index('a',1,3) 找不到则会报错 str.find('a',1,4) 从索引1-4之间寻找,如果找不到则返回-1
阅读全文
posted @ 2018-01-18 16:29 党佳飞
阅读(652)
评论(0)
推荐(0)
序列类型的方法
摘要: 列表的方法: 列表的添加 a = [1, 2, 3, 'a', 'b'] a.append('s') 追加,在末位追加 a.insert(0, 'c') 插入,0表示插入的位置 a.extend([5, 'e']) 扩展 ,把列表里面的元素添加进去 append和extend的区别: append
阅读全文
posted @ 2018-01-18 14:37 党佳飞
阅读(255)
评论(0)
推荐(0)
01序列类型
摘要: 序列类型: 列表、元组、字符串 1. 字符串(str) 用引号或双引号 表示,三引号表示多行字符串 2. 列表 a = [1, 2, 3, 4, 5, 6, 7, 8] 列表 list 3. 元组 a = (1, 2, 3, 4, 5, 6, 7, 8) 元组 tuple 元组和列表的区别: 只有列
阅读全文
posted @ 2018-01-18 13:57 党佳飞
阅读(272)
评论(0)
推荐(0)
01数值类型
摘要: 判断数值类型: 整型、浮点型、布尔值类型(0、1)、复数 1.type(数值) 精确数值计算: 1.导入decimal模块: import decimal a = decimal.Decimal(' 2.2 ') b = decimal.Decimal( ' 2 ') a - b 结果: Decim
阅读全文
posted @ 2018-01-18 12:06 党佳飞
阅读(109)
评论(0)
推荐(0)
python字符串/元组/列表/字典之间的相互转换
摘要: #-*-coding:utf-8-*- #1、字典 dict = {'name': 'jiafei', 'age': 22, 'class': 'ceshi'} #字典转为字符串,返回: {'age': 22, 'name': 'jiafei', 'class': 'ceshi'} print(type(str(dict)), str(dict)) #字典可以转为元组,返回:('age',...
阅读全文
posted @ 2018-01-18 11:16 党佳飞
阅读(282)
评论(0)
推荐(0)
公告