![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
沉默之剑TAO
在校大学生
展开
-
python基础
本章主要介绍了python的基础,包括了基础语法,字符串,元组,列表,字典,函数,文件。欢迎在评论区多多交流。 python基础 注释 单行注释 实例 ```python # 单行注释 print("hello wold") ``` 多行注释 实例 ```python ''' 多行注释 多行注释 多行注释 多行注释 ''' print("hello wol...原创 2018-04-08 14:53:41 · 115 阅读 · 0 评论 -
python面向对象
本章主要总结了python的面向对象编程,包括了类,对象,方法,继承,多态,设计模式(工厂模式、单例模式),异常 类和对象 类的定义 实例:定义一个Car类 ```python #定义类 class Car: #方法 def getCarInfo(self): print("我是一个车类") ``` 在创建方法是,会有一个self参数,那什么是s...原创 2018-04-08 14:55:22 · 136 阅读 · 0 评论 -
python高级
作用域 locals和globals locals为局部变量,globals为全局变量 locals实例: ```python A = 100 B = 200 def test(): a = 11 b = 22 print(locals()) test() ``` 输出结果: globals实例: ```python A = 100 B = 200...原创 2018-05-06 14:06:56 · 201 阅读 · 0 评论 -
python面向对象进阶
元类 首先,类也是一种对象,只要使用关键字class,python解释器在执行的时候就会创建一个对象。你就可以给他赋值一个变量、拷贝它、增加属性、将它作为函数参数进行传递。 使用type创建类 type可以动态的创建类,它可以接受一个类的描述作为参数,然后返回一个类。 使用方法:type(类名,由父类名称组成的元组(可以为空),包含属性的字典) 来看一个实例: ```python ...原创 2018-05-06 14:08:19 · 124 阅读 · 0 评论 -
python数据结构之链表
单链表 节点实现 ```python class Node(object): """节点""" def __init__(self, elem): self.elem = elem self.next = None ``` 头部添加元素 ```python def add(self, item): """在头部添加元...原创 2018-05-06 14:09:35 · 205 阅读 · 0 评论 -
python数据结构之栈与队列
栈 ```python class Stack(object): def __init__(self): self.__list = [] def push(self, item): self.__list.append(item) def pop(self): return self.__list.pop() ...原创 2018-05-06 14:10:38 · 170 阅读 · 0 评论 -
python数据结构之树
```python class Node(object): def __init__(self, item): self.elem = item self.lchild = None self.rchild = None class Tree(object): def __init__(self): self.roo...原创 2018-05-06 14:11:49 · 233 阅读 · 0 评论 -
python数据结构之排序与搜索
冒泡排序 ```python def bubble_sort(alist): """冒泡排序""" n = len(alist) for j in range(n-1): count = 0 for i in range(0, n-1-j): if alist[i] > alist[i+1]: ...原创 2018-05-06 14:12:48 · 177 阅读 · 0 评论