【发布时间】:2012-12-06 14:53:04
【问题描述】:
给定以下字符串;
....00.3276021,,,constString1=31;garbage=00:00:00.0090000;constString2=16;garbage2=00.00...
如何提取constString1 和constString2 的值,以便将它们分配给变量。例如:
string1_cummulativeTotal += [the magic returning the int]
string2_cummulativeTotal += [the magic returning the int]
谢谢!
【问题讨论】:
-
一个很好的问题是这个字符串是从哪里来的?它可能会影响答案的编写方式,如果您按照下面的建议从 CSV 中读取数据,那么您可能会有更好的解决方案,此外,如果您有可能要捕获更多“constStrings”,或者他们的顺序可能会改变,这对我们来说应该很重要。
标签: python regex file-io readline