[英]Which serialization format is this?
I'm dealing with some serialized data fetched from an SQL Server database and that looks like this:我正在处理从 SQL 服务器数据库中获取的一些序列化数据,它看起来像这样:
('|AFoo|BBaar|C61|DFoo Baar|E200060|F200523|G200240|', )
Any idea which format is this?知道这是什么格式吗? And is there any Python package that can deserilize this?有没有 Python package 可以反序列化这个?
What you show is a tuple that contains one value - a string.您显示的是一个包含一个值的元组 - 一个字符串。 You can use string.split to construct a list of the string's component parts - ie, AFoo, BBaar etc您可以使用 string.split 来构造字符串的组成部分列表 - 即 AFoo、BBaar 等
t = ('|AFoo|BBaar|C61|DFoo Baar|E200060|F200523|G200240|', )
for e in t:
values = [v for v in e.split('|') if v]
print(values)
Output: Output:
['AFoo', 'BBaar', 'C61', 'DFoo Baar', 'E200060', 'F200523', 'G200240']
Note:笔记:
The for loop is used as a generic approach that allows for multiple strings in the tuple. for循环用作允许在元组中使用多个字符串的通用方法。 For the data fragment shown in the question, this isn't actually necessary对于问题中显示的数据片段,这实际上不是必需的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.