弄了一个函数,仅将list中的str全部变成小写,其他数据保持不变~~^^~~
def convert_i(L): if not isinstance(L,list): raise TypeError('please enter list') L1=dict(enumerate(L)) l1=[] for key,value in L1.items(): if isinstance(value,str): L1[key]=value.lower() else: pass L=list(L1.values()) return L
用列表生成式的话只需要一行代码
Sign in to make a reply
小叶子96652
弄了一个函数,仅将list中的str全部变成小写,其他数据保持不变~~^^~~