摘要: python 类与对象 python 类与对象(未完待续) 类 定义 括号里的是继承类,如果没有类继承,就继承object类,它是所有类的基础类。 pass 是占位符,还可用在判断和循环中 class 类名(object): pass # 栗子如下 class Person(object): pass # 定义对象per1 阅读全文
posted @ 2023-01-18 15:14 勤匠 阅读(36) 评论(0) 推荐(0) 编辑
摘要: python pip实用手册 pip是python的包安装工具,类似于JavaScript的npm和yarn 设置国内源 国内源 清华 https://pypi.tuna.tsinghua.edu.cn/simple 阿里 http://mirrors.aliyun.com/pypi/simple/ 中科大 https://py 阅读全文
posted @ 2023-01-18 09:48 勤匠 阅读(63) 评论(0) 推荐(0) 编辑
摘要: python序列 类似于Java和C的数组,但python的”数组“可操作性更强,以下是常用API insert 指定位置插入 arr = [0, 1, 20, 3, 40, 5, 60, 7, 80, 9] # 下标1位置后加入值,结果[0, 1, 81, 20, 3, 40, 5, 60, 7, 80, 9] a 阅读全文
posted @ 2023-01-18 09:46 勤匠 阅读(24) 评论(0) 推荐(0) 编辑
摘要: python方法(函数) 定义格式 def 方法名(参数1,参数2,参数3): # 具体实现 return #返回值 参数默认值 def desc(name='no-name',age=0): print("%s %d"%(name,age)) # 调用 desc() # no-name 0 desc("jack",10) 阅读全文
posted @ 2023-01-18 09:45 勤匠 阅读(15) 评论(0) 推荐(0) 编辑