Skip to main content
 首页 » 编程设计

Python 字符串拆分返回奇怪的字符

2025年01月19日21www_RR

<分区>

string = '''In your opinion, will BCH/USD trade above 1500 USD (+9.65%) at anу timе bеfore Арril 28? 
Indicаtоr: 60.76%''' 
 
splited = string.split() 
print(splited) 
 
# Using Regex 
import re  
 
res = re.findall(r"\w+ \d+\?", string) 
print(res) 

我想从这个字符串中获取 4 月 28 日这个日期。如果我拆分字符串,它会产生这样的输出

an\xd1\x83', 'tim\xd0\xb5', 'b\xd0\xb5fore', '\xd0\x90\xd1\x80ril', '28? 

如果我使用正则表达式它只返回

ril 28 

如何获取日期或转换字符串,使其像普通字符串一样工作?

Demo