![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python入门
Python入门课程学习博客
浅行漫漫路
这个作者很懒,什么都没留下…
展开
-
05类与对象
类与对象 定义类 初始化函数中,self后面的是实例化对象的属性。 加下划线代表这个属性是私有的,不应该被外界直接访问 class Person: def __init__(self, name, age): self._name = name self._age = age def hello(self): print("My name is {}, age is {}".format(self._name, self._age)) p原创 2020-05-28 09:26:58 · 119 阅读 · 0 评论 -
04函数
函数 名称:函数命名遵循变量命名规范 参数: 位置参数:多个参数间不可交换位置 关键字参数:对应即可 返回值:默认返回None 参数的收集 一个星(*):表示接收的参数作为元组来处理,收集位置参数 两个星(**):表示接收的参数作为字典来处理,收集关键字参数 装饰器 在程序中,不会对原来函数造成改变,还要增添新的功能,调用函数时的接口没有发生变化。 https://www.bilibili.com/video/BV1d7411h794?from=search&seid=1622922965424原创 2020-05-28 09:26:27 · 111 阅读 · 0 评论 -
03流程控制
流程控制 if语句: print("请输入账号:") username = input() if username == 'wang': print("登录成功") elif username == 'admin': print("管理员账号") else: print("账号不存在") 断言: age = 19 assert age == 18, "她竟然不是18岁" for循环/while循环: 尽量使用for循环 当循环的条件和数量没有关系的时候使用while循环原创 2020-05-28 09:26:02 · 148 阅读 · 0 评论 -
02Python数据类型
Python数据类型 数值 int float complex bool 字符串 str 列表 list 元组 tuple 字典 dict bool型 True(1) False(0) 运算符:and or 字符串 str 转义字符/ “格式化工具: {}”.format(“format”) len():返回字符串的长度 id():返回内存地址 type():返回数据类型 切片操作: string[:10] # 取前10个字符 string[0:10:2] # 取前10个字符, 每隔一个取一个 s原创 2020-05-22 20:17:59 · 110 阅读 · 0 评论 -
01Python入门
Python入门 本专题的目标 掌握基本的Python语法,编写简单的py程序 编写简单的爬虫 基本的数据分析 Python的特性 语法简单,容易理解 跨平台 有强大、丰富的第三方库 作用:网站、爬虫、大数据处理、机器学习…… Hello World import this print("Hello") print("World") # 输出: # Beautiful is better than ugly. # Explicit is better than implicit. # Simpl原创 2020-05-22 09:38:52 · 101 阅读 · 0 评论