tuple元胞数组:
1 | numl=set([1,2,3,4,5,3,1]) |
函数嵌套:汉诺塔 PythonObj/IDLE练习/hanoi.py
1 | def hanoi(n,x,y,z): |
dic的使用:
1 | dict1=dict((('a',10),('b',20),('c',30),('d',40),('e',50),('f',60))) |
file的使用
1 | with open("C:/Users/10921/Desktop/1.txt") as b:#默认rb二进制只读模式,且使用完毕自动删除b |
文件系统
1 | import os |
永久存储:
pickle包:pkl文件,dump,load
1 | import pickle |
类和对象:
self
1 | class Ball: |
魔法方法(构造方法):1
2
3
4
5
6
7
8
9
10
```python
>>> class Ball
def __init__(self,name):
self.name=name
def kick(self):
print("我叫%s,该死的,谁踢我" %(self.name))
>>> d=Ball('王大锤')
>>> d.kick()
我叫王大锤,该死的,谁踢我
公有私有变量的定义和调用
1 | class Person: |
继承inherit语法:
1 | class Parent: |
1 | mudule:fish_inherit.py |
1 |
1 |