Open pimgeek opened 6 years ago
import decimal arr = [[1,' a ', 3.0 ],[' 4?' ,5.112321E15, None]] def isfloat(val): try: float(val) return True except: return False def isint(val): try: int(val) return True except: return False def mystr(val): if (isfloat(val)): return val else: return str(val) def mystrip(val): if (isint(val)): return val else: return val.strip(' ?') new_arr = [] for row in arr: tmp1 = list(map(mystr, row)) tmp2 = list(map(mystrip, tmp1)) new_arr.append(tmp2) print(new_arr)