python
Dx丶
这个作者很懒,什么都没留下…
展开
-
Python数据结构和模块
Python 数据结构List 列表Method 方法 append(v) 在列表添加元素 extend(L) 扩展列表 参数为列表 insert(i,v) 在指定的索引插入元素 remove(item) 删除指定元素 pop(i) 移除指定索引元素并返回 count(item) 返回指定元素的个数 sort() 排序 reverse() 排序反转 clear() 清除元素 == del list[原创 2017-10-19 07:49:39 · 284 阅读 · 0 评论 -
Python输入和输出
输入和输出 str(): 函数返回一个用户易读的表达形式。 repr(): 产生一个解释器易读的表达形式。 输出格式 str.rjust(length) 输出的长度为length,右对齐 str.ljust(length) 输出的长度为length,左对齐 str.center(length) 输出的长度为length,居中 str.zfill(len原创 2017-10-19 19:49:42 · 248 阅读 · 0 评论 -
Python 错误和异常
错误和异常异常处理格式try: #代码块 except: #异常捕捉 else: #没发生异常执行 finally: #不管异常是否发生都执行 抛出异常 使用raise关键字 rasie Error 自定义异常class MyError(Exception): def __init__(self,value) self.value = va原创 2017-10-20 23:01:10 · 176 阅读 · 0 评论 -
Python 类和对象
Python 类和对象类 使用关键字 class 定义一个类 类的基本属性和私有属性的定义 私有方法的定义 class People: # 定义基本属性 name = '' age = 0 # 定义私有属性 只能在类的内部访问 __weight = 0 # 构造方法:当实例化原创 2017-10-22 14:34:34 · 184 阅读 · 0 评论 -
了解Python 必备标准库
Python 标准库os 操作系统接口print(os.getcwd()) # 返回当前的工作目录 # os.chdir("F:/") # 修改当前工作目录 print(os.getcwd()) # os.system("mkdir today") # 执行系统命令mkdir shutil 日常的文件和目录管理任务shutil.copyfile('ex1.py', 'file/copyEx1.原创 2017-10-22 17:42:41 · 232 阅读 · 0 评论