Python 3.x 如何从python中包含一系列字符的字符串中获取devnagri子字符串
以下是我的示例字符串:Python 3.x 如何从python中包含一系列字符的字符串中获取devnagri子字符串,python-3.x,unicode,substring,hindi,Python 3.x,Unicode,Substring,Hindi,以下是我的示例字符串: string = 'this is a string 3.158 बात करना है' 我想要一个函数,它将此字符串作为参数并返回: 'बात करना है' 该模块允许您访问正则表达式中的unicode属性。因此,您可以使用\p{script=devnagri}属性来匹配devnagri字符devnagri字母的Windows XP alt代码介于2309和2416之间。 因此,您可以使用以下代码: s = 'this is a string 3.158 बा
string = 'this is a string 3.158 बात करना है'
我想要一个函数,它将此字符串作为参数并返回:'बात करना है' 该模块允许您访问正则表达式中的unicode属性。因此,您可以使用\p{script=devnagri}属性来匹配devnagri字符devnagri字母的Windows XP alt代码介于2309和2416之间。 因此,您可以使用以下代码:
s = 'this is a string 3.158 बात करना है'
for n,i in enumerate(s):
if ( 2309 < ord(i) < 2416 ) or (i==' ') and ( 2309 < ord(s[n-1]) <2416 ):
print(i,end='')
这是一个字符串3.158बात करना है'
对于n,枚举中的i:
如果(2309