摘要: # method 方法# staticmathod 静态的方法 ***# classmethod 类方法 ****# 类的操作行为class Goods: __discount = 0.8 def __init__(self,name,price): self.name = name self.__ 阅读全文
posted @ 2019-06-13 17:32 18软件工程五班陈星星 阅读(161) 评论(0) 推荐(0) 编辑
摘要: # property # 内置装饰器函数 只在面向对象中使用from math import piclass Circle: def __init__(self,r): self.r = r @property def perimeter(self): return 2*pi*self.r @pro 阅读全文
posted @ 2019-06-12 17:13 18软件工程五班陈星星 阅读(202) 评论(0) 推荐(0) 编辑
摘要: class Room: def __init__(self,name,length,width): self.__name = name self.__length = length self.__width = width def get_name(self): return self.__nam 阅读全文
posted @ 2019-06-11 19:30 18软件工程五班陈星星 阅读(184) 评论(0) 推荐(0) 编辑
摘要: import osprint(os.getcwd())os.chdir(r'C:\Users\Administrator\PycharmProjects')print(os.getcwd())os.chdir('..')print(os.getcwd())os.makedirs('dirname1/ 阅读全文
posted @ 2019-06-10 19:30 18软件工程五班陈星星 阅读(123) 评论(0) 推荐(0) 编辑
摘要: try: print('1111') # 1/0 print('2222') # name # 2+'3' # [][3] # {}['k'] ret = int(input('number >>>')) print(ret*'*')except ValueError: print('输入的数据类型 阅读全文
posted @ 2019-06-06 19:03 18软件工程五班陈星星 阅读(166) 评论(0) 推荐(0) 编辑
摘要: # 把解决一类问题的模块放在同一个文件夹里 —— 包policy.get()import osos.makedirs('glance/api')os.makedirs('glance/cmd')os.makedirs('glance/db')l = []l.append(open('glance/_ 阅读全文
posted @ 2019-06-05 14:27 18软件工程五班陈星星 阅读(168) 评论(0) 推荐(0) 编辑
摘要: # 计算器# 首先得到一个字符串# 去空格# 没有空格的字符串# 先算最里层括号里的 : 找括号 ,且括号里没有其他括号# 得到了一个没有括号的表达式 :只有加减乘除# 从左到右先找到第一个乘除法 : # 循环 # 乘除法第一个数的符号是不必匹配的 # 找到乘除法如何计算呢: # 先判断是乘法还是除 阅读全文
posted @ 2019-06-04 14:02 18软件工程五班陈星星 阅读(286) 评论(0) 推荐(0) 编辑
摘要: #列表、元祖#字典#集合、frozenset#字符串#堆栈 : 先进后出#队列 :先进先出 FIFOfrom collections import namedtuplePoint = namedtuple('point',['x','y','z'])p1 = Point(1,2,3)p2 = Poi 阅读全文
posted @ 2019-06-03 16:46 18软件工程五班陈星星 阅读(211) 评论(0) 推荐(0) 编辑
摘要: import timetime.sleep(100)print(time.time())print(time.strftime("%Y-%m-%d %a %H:%M:%S")) #year month day HOUR MINUTE SECONDprint(time.strftime("%Y/%m/ 阅读全文
posted @ 2019-05-31 13:57 18软件工程五班陈星星 阅读(268) 评论(0) 推荐(0) 编辑
摘要: import refrom urllib.request import urlopendef getPage(url): response = urlopen(url) return response.read().decode('utf-8')def parsePage(s): ret = re. 阅读全文
posted @ 2019-05-30 22:08 18软件工程五班陈星星 阅读(181) 评论(0) 推荐(0) 编辑