好的,以下是使用Python中的zlib库的compressobj对象进行压缩和解压缩的示例代码:
```python
import zlib
# 压缩字符串
original_str = "xmppxmpp"
compressor = zlib.compressobj()
compressed_data = compressor.compress(original_str.encode()) + compressor.flush()
# 解压缩数据
decompressor = zlib.decompressobj()
decompressed_data = decompressor.decompress(compressed_data)
decompressed_str = decompressed_data.decode()
print("原始字符串:", original_str)
print("压缩后的数据:", compressed_data)
print("解压缩后的数据:", decompressed_data)
print("解压缩后的字符串:", decompressed_str)
```
输出结果与上面的示例代码相同。