上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页
摘要: 1,find [PATH] [option] [acion] 查找命令 2,ls 展示文件夹内容 -a 全部文档,连同隐藏文档(以.开头的文档)一起列出来 3,cd 切换目录 4,tree 显示树形的层级目录结构,非原生命令,需要安装tree 5,cp 复制文件 6,rm 删除文件 7,mv 移动文件 8,pwd 查看当前工作目录的完整路径 9,tar 用于压缩解压 10,mkdir 创建目录(文 阅读全文
posted @ 2019-08-27 18:25 月为暮 阅读(159) 评论(0) 推荐(0) 编辑
摘要: # # 利用描述符原理定义一个@classmethod # class ClassMethod: # def __init__(self,func): # self.func = func # def __get__(self,instance, owner): # # 类来调用,instance为None,owner为类本身, # # 实例来调用,instance为实例,owner为类本身, # 阅读全文
posted @ 2019-08-27 17:37 月为暮 阅读(113) 评论(0) 推荐(0) 编辑
摘要: class StaticMethod: def __init__(self,func): self.func=func def __get__(self, instance, owner): #类来调用,instance为None,owner为类本身,实例来调用,instance为实例,owner为类本身, print("hhahaha") def feedback(*args,**kwargs) 阅读全文
posted @ 2019-08-27 17:36 月为暮 阅读(121) 评论(0) 推荐(0) 编辑
摘要: # 先回顾一下 class Room: def __init__(self,name,width,length): self.name = name self.width = width self.length = length @property def area(self): return self.width * self.length r1 = Room('wang',100,100) p 阅读全文
posted @ 2019-08-27 17:35 月为暮 阅读(250) 评论(0) 推荐(0) 编辑
摘要: # 描述符,相当于一个代理 class Str: def __init__(self,name): self.name = name # 取值操作时使用 # instance:传入对象 # owner:对象的类 def __get__(self, instance, owner): print("get >",instance,owner) # 返回对象的name属性 return instanc 阅读全文
posted @ 2019-08-18 14:32 月为暮 阅读(141) 评论(0) 推荐(0) 编辑
摘要: class School: def __init__(self,name,addr,type): self.name=name self.addr=addr self.type=type def __repr__(self): return 'School(%s,%s)' %(self.name,self.addr... 阅读全文
posted @ 2019-08-18 12:14 月为暮 阅读(188) 评论(0) 推荐(0) 编辑
摘要: # class Foo: # def __init__(self,x): # self.x = x # def __getattr__(self,item): # print("__getattr__") # # return self.__dict__[item] # def printer(self): # print("lsdajfl") # # f1 = Foo(10) # print(f 阅读全文
posted @ 2019-08-18 12:02 月为暮 阅读(150) 评论(0) 推荐(0) 编辑
摘要: class Foo: x = 1 def __init__(self,y): self.y = y def __getattr__(self,item): print(" >from getattr:你找的属性不存在") def __setattr__(self,key,value): print(' > from setattr') # self.key = value # 这样就无限递归 # 阅读全文
posted @ 2019-08-18 12:00 月为暮 阅读(127) 评论(0) 推荐(0) 编辑
摘要: # 反射主要是程序可以访问,监测和修改它本身状态或行为的一种能力(自省)。 # 四个可以实现自省的函数 # hasattr(object,name) 判断object中有没有一个name字符串对应的方法或者属性 #getattr(obj, attr,default = None): # 调用这个方法将返回obj中名为attr值的属性的值,例如如果attr为'bar',则返回obj.bar。 # 没 阅读全文
posted @ 2019-08-18 11:00 月为暮 阅读(131) 评论(0) 推荐(0) 编辑
摘要: # os模块是与操作系统交互的一个接口 import os print(os.getcwd()) # 获取当前工作目录,当前python文件的目录路径 # os.chdir('02random模块.py') print(os.curdir)# 返回当前目录: ('.') print(os.pardir) # 获取当前目录的父目录字符串名:('..') # os.makedirs('dirname1 阅读全文
posted @ 2019-08-17 20:54 月为暮 阅读(219) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页