ermutuxia

2021-03-27   阅读量: 536

如何用python正则表达式删掉一个字符串里的标点符号和数字?

扫码加入数据分析学习群

如何用python正则表达式删掉一个字符串里的标点符号和数字?换句话说就是只保留字符串里面的中文,英文。

import re
str1 ='economy gains 227,000 jobs in january under president trump - breitbart,katie mchugh,the u. s. economy gained 227, 000 jobs in january according to statistics released by the labor department on friday, while unemployment ticked up slightly to 4. 8 percent. [wages also increased 2. 5 percent compared to january 2016, rising six cents in december.  the economy added 157, 000 jobs in december and unemployment stood at 4. 7 percent. a number of companies announced before trump’s inauguration they planned to expand in the u. s. not overseas, and hire american workers. these included ford, sap se, amazon. com, lockheed martin, gm, bayer ag, walmart, and many more. employers have also found themselves managing a tighter employment market, according to the new york times: regardless of government estimates, however, employers across sectors and across the nation have increasingly complained about the difficulty of finding workers, a competition that kept the increase in the average hourly wage ahead of a 1. 6 percent price inflation rate. “we’re still continuing to see wage pressure as the candidate market continues to shrink,” said amy glaser, senior vice president of adecco staffing usa, which has 300 branch offices. in addition to the omnipresent hunger for engineers, ms. glaser said there is a demand for those with   trade skills like welding that fell into disuse during the recession, as well as   warehouse and light assembly workers. “employers are getting very creative,” said ms. glaser, whose office is in lexington, ky. “we’re seeing   bonuses. they have added sabbaticals to their packages, increases to stock options, free child care on site and free meals. anything to get a competitive edge. ” after election day, many companies, especially small businesses, responded with soaring optimism. during his inaugural address, trump said: “we will follow two simple rules: buy american and hire american. ”'
# 只保留中文、大小写字母
pp1 = "[^A-Za-z\u4e00-\u9fa5]"
str2=re.sub(pp1, ' ', str1)
print(str2)

5.png

1200.0000 1 0 关注作者 收藏

评论(0)


暂无数据

推荐课程