随笔分类 -  编程技术 / python编程 / python3 builtins

摘要:hex函数,参数可以是一个int整数或一个bytes类型元素,转为0x的十六进制字符串形式 with open(file='J:/新建文本文档.txt', mode='rb') as f: s = f.read() print(type(s), s) result = '' for i in s: 阅读全文
posted @ 2023-04-22 23:42 挖洞404 阅读(4) 评论(0) 推荐(0) 编辑
摘要:1、介绍 type本身是内建模块中的一个类,其主要作用是用于判断变量的数据类型。 2、类 class type(object): def __init__(cls, what, bases=None, dict=None): """ type(object_or_name, bases, dict) 阅读全文
posted @ 2023-04-17 09:55 挖洞404 阅读(55) 评论(0) 推荐(0) 编辑
摘要:1、介绍 python3中,可以使用函数len获取容器对象的长度,比如str字符串、list列表等。 2、函数 def len(*args, **kwargs): pass 返回类型为int,如果长度为0,则就返回0 不能对非容器变量使用,会报错,比如int、None值 3、示例 # 不能对非容器变 阅读全文
posted @ 2023-04-17 09:54 挖洞404 阅读(23) 评论(0) 推荐(0) 编辑
摘要:1、介绍 range是一个类,用于帮助for循环。 2、类 class range(object): """ range(stop) -> range object range(start, stop[, step]) -> range object """ def __init__(self, s 阅读全文
posted @ 2023-04-17 09:54 挖洞404 阅读(34) 评论(0) 推荐(0) 编辑
摘要:1、介绍 python3中,可以通过内建模块的open函数,进行文件的读写,以及创建文件。 2、函数 open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=N 阅读全文
posted @ 2023-04-17 09:54 挖洞404 阅读(195) 评论(0) 推荐(0) 编辑
摘要:1、介绍 python3中,使用bytes类处理字节数据。 2、类 class bytes(object): """ bytes(iterable_of_ints) -> bytes bytes(string, encoding[, errors]) -> bytes bytes(bytes_or_ 阅读全文
posted @ 2023-04-17 09:53 挖洞404 阅读(65) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示