定义函数,给定一个列表作为函数参数,将列表中的非数字字符去除
'''定义函数,给定一个列表作为函数参数,将列表中的非数字字符去除。''' class list: def __init__(self,alist): self.alist=alist def remove_str(self): a="" for i in self.alist: b=str(i) a+=b "".join (filter(str.isdigit,a)) print("".join(filter(str.isdigit,a))) a=list([1,2,3,"q",6,"sd","[][]{"]) a.remove_str()
本文来自博客园,作者:Hany47315,转载请注明原文链接:https://www.cnblogs.com/hany-postq473111315/p/12943097.html

浙公网安备 33010602011771号