【发布时间】:2022-07-27 01:36:59
【问题描述】:
假设我在 python 中有以下列表
List= ['Car XXX_2010 Type', 'Length: 14.7', 'Width: 5.8', 'Height: 5.6']
如何从列表的第一个元素中删除“类型”一词,同时保留元素的其余部分?
换句话说,我怎样才能得到这样的输出:
List= ['Car XXX_2010', 'Length: 14.7', 'Width: 5.8', 'Height: 5.6']
【问题讨论】:
-
List[0] = List[0].replace(" Type", "")
标签: python