1. 首页
  2. 数据库
  3. 其它
  4. Python struct.unpack

Python struct.unpack

上传者: 2021-02-23 22:22:26上传 PDF文件 24.36KB 热度 22次
1. 设置fomat格式,如下: 复制代码 代码如下:# 取前5个字符,跳过4个字符华,再取3个字符 format = ‘5s 4x 3s’ 2. 使用struck.unpack获取子字符串 复制代码 代码如下:import struct print struct.unpack(format, ‘Test astring’) #(‘Test’, ‘ing’) 来个简单的例子吧,有一个字符串’He is not very happy’,处理一下,把中间的not去掉,然后再输出。 复制代码 代码如下:import struct theString = ‘He is not very happy’
下载地址
用户评论