Python从字符串中提取中文字符
#coding:utf-8
import re #re是正则表达式模块
def main():
str = input("请输入字符串:")
chinese = re.findall('[\u4e00-\u9fa5]', str) # 汉字的范围为"\u4e00-\u9fa5"
print(chinese)
if __name__ == '__main__':
main()
#coding:utf-8
import re #re是正则表达式模块
def main():
str = input("请输入字符串:")
chinese = re.findall('[\u4e00-\u9fa5]', str) # 汉字的范围为"\u4e00-\u9fa5"
print(chinese)
if __name__ == '__main__':
main()