在字典中加入了26个字母没有用
比如“hello你好”仍然会分成“hello 你好”
我想得到“h e l l o 你好”,请问怎么处理
同样还有shu'zi
import re
sentence="hello你好"
result=re.sub(r"([a-zA-Z])",r"\1 ", sentence)
print(result.rstrip())
或者:
import re
sentence="hello你好"
result=""
for chr in sentence:
if(re.match(r"[a-zA-Z]", chr)):
result+=chr+" "
else:
result+=chr
print(result.rstrip())