摘要:
#类的特殊成员 class Foo(): def __init__(self,name,age): self.age = age self.name = name def __int__(self): return 23 #对象的返回值 #print(obj)就会自动执行对象的__str__方法 # 阅读全文
摘要:
#成员修饰符 #共有成员 name #私有成员 __age #静态方法和静态字段是可以不用创建对象直接进行调用或访问,节省内存, # 所以可直接用类进行访问 class Foo(): #静态字段私有 __hobby = 'basketball' def __init__(self,name,age) 阅读全文
摘要:
#面向对象的分页器 class Pagination(): def __init__(self,current_page): try: p = int(current_page) except Exception as e: p = 1 self.page = int(p) if self.page 阅读全文
摘要:
String的内置方法 st='hello kitty {name} is {age}' print(st.count('l')) # 统计元素个数 print(st.capitalize()) # 首字母大写 print(st.center(50,'#')) # 居中 print(st.endsw 阅读全文
摘要:
#!/usr/bin/env python coding: utf-8 -*- 开发团队: 奶豆的小铺 开发人员: bcz 开发时间: 2020/11/22 20:17 #继承应用场景,修改已有的源代码或者web框架源代码 `class Web(): def show(self,*args): pr 阅读全文
摘要:
#!/usr/bin/env python coding: utf-8 -*- 开发团队: 奶豆的小铺 开发人员: bcz 开发时间: 2020/11/21 20:36 #函数式编程 def foo(name,age,sex,content): print(name,age,sex,content) 阅读全文
摘要:
import os,os.path directory = input('请输入目录或者文件地址:') def getSzie(path): global size size = 0 if os.path.isfile(path): size1 = os.path.getsize(path) siz 阅读全文