摘要:
import package1.Cat.Cat_Main #顶级目录.子目录.模块文件 #待完善 阅读全文
posted @ 2020-11-15 21:07
17。
阅读(40)
评论(0)
推荐(0)
摘要:
import sys print(sys.path) #获取模块文件搜索路径 sys.path[0]='E:\\python' #临时指定新的搜索路径 print(sys.path) print(sys.path[0]) #获取第一个搜索路径 print(sys.platform) #操作系统标识符 阅读全文
posted @ 2020-11-15 20:48
17。
阅读(69)
评论(0)
推荐(0)
摘要:
###os模块存放于Lib/os.py中 import os print(os.environ) #获取操作系统里设置的环境变量 print(os.getcwd()) #返回表示当前工作路径的字符串 print(os.system('ping 127.0.0.1')) #在子shell中执行命令(c 阅读全文
posted @ 2020-11-15 20:28
17。
阅读(83)
评论(0)
推荐(0)
摘要:
import random print(random.random()) #随机生成一个大于0小于1的数 print(random.uniform(-10,-1)) #在[-10,1)范围内获取一个随机浮点数 # 用random.triangular(low,high,mode)返回三角形分布的随机 阅读全文
posted @ 2020-11-15 20:13
17。
阅读(62)
评论(0)
推荐(0)
摘要:
math提供大量数学计算函数 import math print(math.trunc(3.9)) #3.9取整 3 price=3.23 print(math.ceil(price)) #对浮点数x取大整数 4 print(round(3.5)) #对3.5进行5入操作 4 print(round 阅读全文
posted @ 2020-11-15 18:06
17。
阅读(74)
评论(0)
推荐(0)
摘要:
#datetime实例的方法 from datetime import * print(datetime.now()) #返回当天的日期和时间 today=datetime.now() #定义today为当天日期时间对象 print(datetime.date(today)) #返回当天的日期对象 阅读全文
posted @ 2020-11-15 17:54
17。
阅读(54)
评论(0)
推荐(0)
摘要:
##内置对象 | 英文名称 | 中文名称|说明 | | | | | | Built-in Functions | 内置函数 |print()等 | | Built-in Constants | 内置常量 |False等 | | Built-in Types | 内置类型 | | | Built-in 阅读全文
posted @ 2020-11-15 17:13
17。
阅读(332)
评论(0)
推荐(0)
摘要:
#面对对象核心方法 ###1.封装:现实世界中存在的某个客观的属性与行为绑定在一起,并放在一个逻辑单元内. 通过动态类把属性定义,方法定义(其实是数据变量,函数)集成在一起就是封装. ###2.继承 ###3.多态:相同的函数可作用于多种类型的对象上并获得不同的结果. 继承关系多了,有时想确认子类与 阅读全文
posted @ 2020-11-15 16:56
17。
阅读(60)
评论(0)
推荐(0)
摘要:
#静态类 可以创建实例的类叫做动态类(Dynamic Class),不支持实例的叫静态类(Static Class) class StaticC(): name = 'Tom' #类局部变量,没有定义属性的说法 age = 20 address = 'China' call = 1314520 de 阅读全文
posted @ 2020-11-15 16:29
17。
阅读(50)
评论(0)
推荐(0)
摘要:
###编写一个文件Class_module,py class Box1(): #类定义 '''求立方体的类''' def __init__(self,length1,width1,heigth1,c1=0): #传递参数的保留函数__init__ self.length=length1 #长数据变量 阅读全文
posted @ 2020-11-15 16:03
17。
阅读(76)
评论(0)
推荐(0)
摘要:
##类定义的变量或函数变成私有的,在名字前加双下划线 class TeatPrivate(): def __init__(self): self.__say='ok' #属性前加__设置私有 def p(self): print(self.__say) def __pl(self): print(s 阅读全文
posted @ 2020-11-15 15:51
17。
阅读(62)
评论(0)
推荐(0)
摘要:
class Box1(): #类定义 '''求立方体的类''' def __init__(self,length1,width1,heigth1,c1=0): #传递参数的保留函数__init__ self.length=length1 #长数据变量 self.width=width1 #宽数据变量 阅读全文
posted @ 2020-11-15 15:44
17。
阅读(65)
评论(0)
推荐(0)

浙公网安备 33010602011771号