计算列表中字符串转换为整型后的和,包含类似于3.5万的字符串
count = 0
list = ['3.5万', '10万', '1000', '158.5']
new_list = []
for i in list:
if i[-1] == '万':
j = float(i.replace('万',''))*10000
new_list.append(int(j))
else:
new_list.append(float(i)) # 如果字符串没有浮点值,都是整数,可以用int(i)
for x in new_list:
count += x
print(count)