本文主要是介绍re.findall-Python字符过滤(前程无忧薪资字符过滤),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import rere.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)
这篇关于re.findall-Python字符过滤(前程无忧薪资字符过滤)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!