通常我用C写入#从一行中获取子字符串
如何剪切字符串? 我有这样一行:
Line 58: Oct 6 16:58:03 INTEG_245 sia_server[6830]: DbsinkConsumer.cc:262: (D) <video> 07920E: Got msg_idx=28 for evt_id=436752
,我需要削减28?
这是我使用的代码:
if (str(line).find("msg_idx=") > 0):
msg_id = line[line.index("Got"):line.index("For")]
得到了一个错误:
sg_id = line[line.index("Got"):line.index("For")]
ValueError: substring not found
将竭诚为例子
你试过字符切片? –
尝试'line.index(“for”)'(小写'f') –
什么是字符串切片? –