#类(面向对象)  PageObject设计模式  unittest 知识体系

#函数式编程
import datetime
book_info = {
"title":"Python",
"price":"33.1",
"auther":"毛桃",
"publisher":"北京大学",
"pubdate":datetime.datetime.today()
}

def seacher_book(book):
print("这本书的主题是:{}".format(book_info["title"]))
print("这本书的价格是:{}".format(book_info["price"]))
print("这本书的作者是:{}".format(book_info["auther"]))
print("这本书的出本社是:{}".format(book_info.get("publisher")))
print("这本书的出版时间是:{}".format(book_info.get("pubdate")))
#
# if __name__ == '__main__':
# seacher_book(book_info)

#构造方法
# class Book:
# def __init__(self,title,author,price,publisher,pubdate):
# self.title = title
# self.author = author
# self.price = price
# self.publisher = publisher
# self.pubdate = pubdate
#
# book = Book("Selenium",'Teacher',"43.33","清华大学",datetime.datetime.today())
# print(book.title)
# print(book.author)
# print(book.price)
# print(book.publisher)
# print(book.pubdate)

#类构造函数
# class Book:
# def __init__(self,title,author,price,publisher,pubdate):
# self.title = title
# self.author = author
# self.price = price
# self.publisher = publisher
# self.pubdate = pubdate
#
# def seacher_book(self):
# print("这本书的主题是:{}".format(self.title))
# print("这本书的价格是:{}".format(self.price))
# print("这本书的作者是:{}".format(self.author))
# print("这本书的出本社是:{}".format(self.publisher))
# print("这本书的出版时间是:{}".format(self.pubdate))
#
# if __name__ == '__main__':
# book = Book("Selenium",'Teacher',"43.33","清华大学",datetime.datetime.today())
# book.seacher_book()

#默认值的写法
# class Book:
# def __init__(self,
# title = "Appium测试",
# author = "",
# price = 0.0,
# publisher = None,
# pubdate = datetime.datetime.now()):
# self.title = title
# self.author = author
# self.price = price
# self.publisher = publisher
# self.pubdate = pubdate
#
# def seacher_book(self):
# print("这本书的主题是:{}".format(self.title))
# print("这本书的价格是:{}".format(self.price))
# print("这本书的作者是:{}".format(self.author))
# print("这本书的出本社是:{}".format(self.publisher))
# print("这本书的出版时间是:{}".format(self.pubdate))
#
# if __name__ == '__main__':
# book = Book("Selenium")
# book.seacher_book()

# #类的继承
# #父类
# class Book:
# def __init__(self,title,author,price):
# self.title = title
# self.author = author
# self.price = price
#
# def seacher_book(self):
# print("这本书的主题是:{}".format(self.title))
# print("这本书的作者是:{}".format(self.author))
# print("这本书的价格是:{}".format(self.price))
#
# #子类
# class ReadBook(Book):
# def readbook(self):
# print("该书正在读中...")
#
#
# #实例化子类
# book = ReadBook("Python经典","Tao","11.42")
# book.seacher_book()
# book.readbook()

#类的重写
#父类
class Book:
def __init__(self,title,author,price):
self.title = title
self.author = author
self.price = price

def seacher_book(self):
print("这本书的主题是:{}".format(self.title))
print("这本书的作者是:{}".format(self.author))
print("这本书的价格是:{}".format(self.price))

#子类
class ReadBook(Book):
#构造方法 --初始化方法 (放的是公共的东西)
def __init__(self,title,author,price,publisher,pubdate):
Book.__init__(self,title,author,price)
self.publisher = publisher
self.pubdate = pubdate

def readbook(self):
print("该书正在读中...")

def seacher_book(self):
print("这本书的主题是:{}".format(self.title))
print("这本书的价格是:{}".format(self.price))
print("这本书的作者是:{}".format(self.author))
print("这本书的出本社是:{}".format(self.publisher))
print("这本书的出版时间是:{}".format(self.pubdate))

#实例化子类
book = ReadBook("Python经典","Tao","11.42","清华大学出版社",datetime.datetime.now())
book.readbook()
book.seacher_book()

最新文章

  1. 前端学HTTP之缓存
  2. [转]JVM指令详解(上)
  3. BZOJ1485: [HNOI2009]有趣的数列
  4. C#中的IntPtr类型
  5. CentOS7安装mysql5.7.11
  6. Asp.Net 之 枚举类型的下拉列表绑定
  7. React-Native学习指南
  8. ACM-进阶之路
  9. C# 连接SQL数据库 常用连接字符串
  10. UML--核心元素之参与者Actor
  11. python 一篇就能理解函数基础
  12. 两个activity的3D翻转动画.md
  13. uWSGI+Django (中)
  14. SSH(poderosa)を使って、さくらのMySQLサーバーに接続する方法
  15. 转载-HashMap1.8源码分析
  16. vs2017 使用Bower 抛出异常ECMDERR Failed to execute "git ls-remote --tags --heads
  17. Centos7中查看IP并启动网卡
  18. 分块读取Blob字段数据(MSSQL)
  19. 使用POI操作Excel时对事先写入模板的公式强制执行
  20. 从零开始的全栈工程师——html篇1.7

热门文章

  1. 2019个嵌入式市场研究,持续的C/C++优势
  2. JAVA复习题(一)基础知识
  3. 尚硅谷Java——宋红康笔记【day6-day10】
  4. 十二、iptables基本管理
  5. 【NX二次开发】Block UI 切换开关
  6. 深度解密:Java与线程的关系
  7. Bert模型实现垃圾邮件分类
  8. 27、myslq更改为不自动提交
  9. 计算机、程序和java简介
  10. Docker学不会?不妨看看这篇文章