【问题标题】:Extract a particular field in '\xxx\xxx\xxx\xxx\xxx\' format in python? [closed]在python中以'\xxx\xxx\xxx\xxx\xxx\'格式提取特定字段? [关闭]
【发布时间】:2016-09-14 03:07:47
【问题描述】:

所以我的字符串看起来像这样:

"\177\260\002\377\004\210\005\001ABC 01\000\000\000\000\000\00074 0-053352\000\0001GD14222393\000\000\r\013\007\336\000\000\377\377\377\377\377\37 7\377\377\377\377\377\377\377\377\377\377\377\001CMUPACSDBHBBU-HHW-AC-BFG\000\ 000\000\000\000\000\000A00\377\377\377\377\377\377\377\377\377\377\177\000\000\0 00\000\000\000\000\000\000\000\000\000"

我想提取00074 0-053352001CMUPACSDBHBBU-HHW-AC-BFG,我想知道是否有任何复杂的方法可以做到这一点?

【问题讨论】:

  • 为什么是那些子字符串?您的提取代码应如何确定要提取的内容?
  • 我的提取是基于字节数的。例如第 9 个字节有 ID
  • 你知道这个字段有多长吗?

标签: python regex python-2.7


【解决方案1】:
sequences = [part for part in mystring.split("\\") if not part.isdigit()]

?

【讨论】:

  • 这个是因为我提取的字段不是纯数字。感谢您指出并为我的不好感到抱歉。
猜你喜欢
  • 2023-03-10
  • 1970-01-01
  • 2012-11-20
  • 1970-01-01
  • 1970-01-01
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多