import re
re.findall
过滤
万/年
'40-80万/年'
if re.findall(r'(.*)\-(.*)\万\/\年', i):
s = re.findall(r'(.*)\-(.*)\万\/\年', i)[0]
print(s)
print(s[0])
('40', '80')
40
前程无忧薪资字符过滤
abb = ['1-1.6万', '1.5-2万', '2-3万·13薪', '1.5-3万·13薪', '40-80万/年', '9.5千-1.4万·13薪', '6-8千', '6-8千·13薪',
'6.5-8.5千·13薪'
, '6.5千-1.3万', '6千-1.2万']
for i in abb:
# 40-80万/年
if re.findall(r'(.*)\-(.*)\万\/\年', i):
s = re.findall(r'(.*)\-(.*)\万\/\年', i)[0]
a = float(s[0])*10000 / 12
# 保留2位小数
a = round(a, 0)
print(a)
print(s)
# '9.5千-1.4万·13薪'
elif re.findall(r'(.*)\千\-(.*)\万\·(.*)\薪', i):
s = re.findall(r'(.*)\千\-(.*)\万\·(.*)\薪', i)[0]
a = float(s[0]) * 1000 * float(s[2]) / 12
# 保留2位小数
a = round(a, 0)
print(a)
print(i)
print(s)
# '2-3万·13薪'
elif re.findall(r'(.*)\-(.*)\万\·(.*)\薪', i):
s = re.findall(r'(.*)\-(.*)\万\·(.*)\薪', i)[0]
a = float(s[0]) * 10000 * float(s[2]) / 12
# 保留2位小数
a = round(a, 0)
print(i)
print(s)
# 6-8千·13薪
elif re.findall(r'(.*)\-(.*)\千\·(.*)\薪', i):
s = re.findall(r'(.*)\-(.*)\千\·(.*)\薪', i)[0]
a = float(s[0]) * 1000 * float(s[2]) / 12
# 保留2位小数
a = round(a, 0)
print(i)
print(s)
# 6千-1.2万
elif re.findall(r'(.*)\千\-(.*)\万', i):
s = re.findall(r'(.*)\千\-(.*)\万', i)[0]
a = float(s[0]) * 1000
# 保留2位小数
a = round(a, 0)
print(i)
print(s)
# '6-8千'
elif re.findall(r'(.*)\-(.*)\千', i):
s = re.findall(r'(.*)\-(.*)\千', i)[0]
a = float(s[0]) * 1000
# 保留2位小数
a = round(a, 0)
print(i)
print(s)
# '6-8万'
elif re.findall(r'(.*)\-(.*)\万', i):
s = re.findall(r'(.*)\-(.*)\万', i)[0]
a = float(s[0]) * 10000
# 保留2位小数
a = round(a, 0)
print(i)
print(s)