new_list =[str(my_data)+'_'for my_data in my_list]
13、判断某个值 是否在列表中
lists =[[1,2],[3,4],[5,6]]if[1,2]in lists:print("[1, 2] is in the list")else:print("[1, 2] is not in the list")if[7,8]in lists:print("[7, 8] is in the list")else:print("[7, 8] is not in the list")
classPerson:def__init__(self, name):
self.name = name
def__eq__(self, other):return self.name == other.name
persons =[Person("Alice"), Person("Bob"), Person("Charlie")]if Person("Alice")in persons:print("Person named Alice is in the list")else:print("Person named Alice is not in the list")if Person("David")in persons:print("Person named David is in the list")else:print("Person named David is not in the list")