
[oeasy]python086方法_method_函数_function_区别 回忆

随机方法

import random help(random)

具体方法 random.randint

帮助手册 help(random.randint)

实例里面的方法 help(name_list)

翻页

帮助手册
help(list)

帮助手册
help(list)

仔细观察

直接找到
help(list.append)

尝试
help(lst.append)

尝试 append

相同之处


分别调用
honglou_list = ["贾宝玉", "林黛玉", "薛宝钗", "史湘云", "晴雯"] sanguo_list = ["刘备","关羽","张飞","赵云"] honglou_list.append("刘姥姥") sanguo_list.append("诸葛亮") honglou_list sanguo_list

废话生成器

现代诗歌

不同

函数

内建函数


添加图片注释,不超过 140 字(可选)
ord函数 help(ord)

help(chr)

添加图片注释,不超过 140 字(可选)
区分


总结
方法(method) | 函数(function) |
|---|---|
需要对象调用 | 无需对象调用 |
根据 对象名字 调用 | 无需名字 直接调用 |
基于类的对象 | 独立的 |
需要self | 不需要self |

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。