当前位置: 首页 > news >正文

最近新闻头条株洲优化公司

最近新闻头条,株洲优化公司,河南建设政务网,万能造假截图生成器目录 一.Python bytearray 函数简介二.Python bytearray 函数使用三.bytearray 与 bytes 区别 1. bytes 不可变字节序列2.bytearray 可变字节序列 四.猜你喜欢 基础 Python 学习路线推荐 : Python 学习目录 Python 基础入门 Python 除了 bytes 字节序列 之外#xf…目录 一.Python bytearray 函数简介二.Python bytearray 函数使用三.bytearray 与 bytes 区别 1. bytes 不可变字节序列2.bytearray 可变字节序列 四.猜你喜欢 基础 Python 学习路线推荐 : Python 学习目录 Python 基础入门 Python 除了 bytes 字节序列 之外还有 bytearray 可变的字节序列具体区别在哪呢顾名思义bytes 是不可变的而 bytearray 是可变的具体本文会有详细的讲解! 一.Python bytearray 函数简介 # !usr/bin/env python # -*- coding:utf-8 _*-Author:猿说编程 Blog(个人博客地址): www.codersrc.com File:Python bytearray 函数.py Time:2021/05/04 07:37 Motto:不积跬步无以至千里不积小流无以成江海程序人生的精彩需要坚持不懈地积累# 1.定义空的字节序列bytearray bytearray() - empty bytearrayarray# 2.定义指定个数的字节序列bytes默认以0填充不能是浮点数 bytearray(int) - bytes array of size given by the parameter initialized with null bytes# 3.定义指定内容的字节序列bytes bytearray(bytes_or_buffer) - mutable copy of bytes_or_buffer# 4.定义指定内容的字节序列bytes bytearray(string, encoding[, errors]) - bytearray# 5.定义指定内容的字节序列bytes只能为int 类型不能含有float 或者 str等其他类型变量 bytearray(iterable_of_ints) - bytearray返回值 : 返回一个新的可变字节序列可变字节序列 bytearray 有一个明显的特征输出的时候最前面会有一个字符 b 标识举个例子 b\x64\x65\x66 bi love you bhttps://www.codersrc.com凡是输出前面带有字符 b 标识的都是字节序列 bytearray 可变的字节序列bytes 是不可变的字节序列; 二.Python bytearray 函数使用 # !usr/bin/env python # -*- coding:utf-8 _*-Author:猿说编程 Blog(个人博客地址): www.codersrc.com File:Python bytearray 函数.py Time:2021/05/04 07:37 Motto:不积跬步无以至千里不积小流无以成江海程序人生的精彩需要坚持不懈地积累if __name__ __main__:# 定义空的字节序列bytearrayb1 bytearray()print(b1)print(type(b1))print(****20)# 定义指定个数的字节序列bytes默认以0填充不能是浮点数b2 bytearray(10)print(b2)print(type(b2))print(*** * 20)# 定义指定内容的字节序列bytesb3 bytes(abc, utf-8)print(b3)print(type(b3))print(*** * 20)# 正常输出b1 bytearray([1, 2, 3, 4]) b\x01\x02\x03\x04# bytes字节序列必须是 0 ~ 255 之间的整数不能含有float类型b1 bytearray([1.1, 2.2, 3, 4]) TypeError: an integer is required# bytes字节序列必须是 0 ~ 255 之间的整数不能含有str类型b1 bytearray([1, a, 2, 3]) TypeError: an integer is required# bytes字节序列必须是 0 ~ 255 之间的整数不能大于或者等于256b1 bytearray([1, 257]) ValueError: bytes must be in range(0, 256) 输出结果bytearray(b) class bytearray ************************************************************ bytearray(b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00) class bytearray ************************************************************ babc class bytes ************************************************************三.bytearray 与 bytes 区别 相同点bytearray 与 bytes 取值范围都是 0 ~ 256 ;不同点bytearray 可变的字节序列bytes 是不可变的字节序列 ; 1. bytes 不可变字节序列 # !usr/bin/env python # -*- coding:utf-8 _*-Author:猿说编程 Blog(个人博客地址): www.codersrc.com File:Python bytearray 函数.py Time:2021/05/04 07:37 Motto:不积跬步无以至千里不积小流无以成江海程序人生的精彩需要坚持不懈地积累if __name__ __main__:# bytes不可变字节序列b1 babcdfor i in b1:print(i,end )print()b1[0] A 输出结果97 98 99 100 Traceback (most recent call last):File E:/Project/python/python_project/untitled10/123.py, line 22, in moduleb1[0] A TypeError: bytes object does not support item assignment2.bytearray 可变字节序列 # !usr/bin/env python # -*- coding:utf-8 _*-Author:猿说编程 Blog(个人博客地址): www.codersrc.com File:Python bytearray 函数.py Time:2021/05/04 07:37 Motto:不积跬步无以至千里不积小流无以成江海程序人生的精彩需要坚持不懈地积累if __name__ __main__:# bytearray可变字节序列b1 babcdb2 bytearray(b1)print(修改之前,b2)b2[0] 65print(修改之后, b2) 输出结果修改之前 bytearray(babcd) 修改之后 bytearray(bAbcd)四.猜你喜欢 Python for 循环Python 字符串Python 列表 listPython 元组 tuplePython 字典 dictPython 条件推导式Python 列表推导式Python 字典推导式Python 函数声明和调用Python 不定长参数 *argc/**kargcsPython 匿名函数 lambdaPython return 逻辑判断表达式Python 字符串/列表/元组/字典之间的相互转换Python 局部变量和全局变量Python type 函数和 isinstance 函数区别Python is 和 区别Python 可变数据类型和不可变数据类型Python 浅拷贝和深拷贝 未经允许不得转载猿说编程 » Python bytearray 函数
http://www.pierceye.com/news/771404/

相关文章:

  • 常州市网站优化汕头网站建设和运营
  • wordpress 同分类评论调用seo排名是什么
  • 网站建设推广怎么玩软件开发模型是什么
  • 网站开发报价表格海口注册公司代理公司地址电话
  • 西宁好的网站建设视频网站文案
  • 郑州网站优化网络建设有限公司网站建设 交单流程
  • 网站搬家内页打不开重庆市建设工程信息网怎么进不去
  • 深圳 做公司网站网站用什么建设
  • 网站更换空间对优化的影响营销号视频生成器手机版
  • 南宁大型网站推广公司昆山网站制作哪家好
  • 格尔木哪里有做网站的wordpress编辑器排版
  • 怎样开电商襄阳抖音seo找哪家
  • 个人网站 域名舞阳专业做网站
  • 做国外购物网站凤山网站seo
  • 苏州制作网站的有几家WordPress文章编辑链接
  • 免费看电视剧的网站2021网站建设坂田
  • 网站建设中 目录怎么做更好wordpress最好用的虚拟主机
  • 网站百度网盘南京市建设局网站
  • 让别人做网站多久开始注册域名公司注册地址提供
  • 手机网站 设计趋势建设银行暑期招聘网站
  • 兰山做网站专业深圳网站定制开发
  • 做与食品安全有关的网站徐州企业网站设计
  • 番禺网站建设策划江阴市建设局官网站
  • 建设网站模块需要哪些内容石家庄城乡建设厅网站
  • 公司网站后台管理网络公司名字大全三字
  • 广西住房建设厅网站广州seo工作
  • 做分销商城网站的wordpress 知更鸟 网格
  • 推销商务网站的途径有哪些爱网站查询挖掘工具
  • 苏州现代建设公司网站备案的域名做电影网站
  • 长沙seo网站优化公司wordpress5.1下载