这篇文章主要为大家详细介绍了Python 将字符串的中英文分离的完整代码,具有一定的参考价值,可以用来参考一下。
感兴趣Python 将字符串的中英文分离的完整代码的小伙伴,下面一起跟随四海网的小编罗X来看看吧。
# 四海网网 (www.q1010.com)
s = "China's Legend Holdings will split its several business arms to go public on stock markets, the group's president Zhu Linan said on Tuesday.该集团总裁朱利安周二表示,中国联想控股将分拆其多个业务部门在股市上市。"
result = "".join(i for i in s if ord(i) < 256)
print(result)
# End 512.笔记 www.q1010.com
out:
China's Legend Holdings will split its several business arms to go public on stock markets, the group's president Zhu Linan said on Tuesday.
# 四海网网 (www.q1010.com)
import re
s = "China's Legend Holdings will split its several business arms to go public on stock markets, the group's president Zhu Linan said on Tuesday.该集团总裁朱利安周二表示,中国联想控股将分拆其多个业务部门在股市上市。"
uncn = re.compile(r'[\u0061-\u007a,\u0020]')
en = "".join(uncn.findall(s.lower()))
print(en)
# End 512.笔记 www.q1010.com
out:
chinas legend holdings will split its several business arms to go public on stock markets, the groups president zhu linan said on tuesday
本文来自:http://www.q1010.com/181/2614-0.html
注:关于Python 将字符串的中英文分离的完整代码的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:中英文
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。