data = ["abc.mp4", "efg.mp4", "oprste.mp4"]
data = [ele[0:-4] for ele in data]
data = [ele.rsplit(".", 1)[0] for ele in data]
- 把mp4的后缀名去掉
- 需要注意,如果等号右边操作是在原列表中进行,可能会出现问题
- 为防止还在原列表中操作,最好定义新列表变量
info = {
"name": "Jack",
"email": "a@163.com",
"sex": "Female"
}
data_list[]
for k, v in info.items():
temp = "{}-{}".format(k, v)
data_list.append(temp)
result.join = "; ".join(data)
result = "; ".join(["{}-{}".format(k,v) for k, v in info.items()])
result = ["{}-{}".format(item[0], item[1]) for item in info.items()]