印地语单词长度
我试图找出Python中印地语单词的长度,例如据我所知,“प्रवीण”的长度为3。
w1 = 'प्रवीण'
print(len(w1))
我尝试了这段代码,但没有成功。
I am trying to find out the length of Hindi words in Python, like 'प्रवीण' has length of 3 as per my knowledge.
w1 = 'प्रवीण'
print(len(w1))
I tried this code but it didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如@betelgeuse 所说,印地语并不像你想象的那样发挥作用。这里有一些伪代码(有效)可以完成您所期望的操作:
输出
3
。不过,您可以根据需要自定义它。编辑:确保您使用 python 3.x 或在 python 2.x 中使用
u
前缀印地语字符串,我之前在某处看到过 python 2.x 非 unicode 编码的一些语言错误...As @betelgeuse has said, Hindi does not function the way you think it does. Here's some pseudocode (working) to do what you expect though:
This outputs
3
. It's up to you to customize it as you'd like, though.Edit: Make sure you use python 3.x or prefix Hindi strings with
u
in python 2.x, I've seen some language errors with python 2.x non-unicode encoding somewhere before...在印地语中,每个字符的长度不必像英语中那样为一。例如,
वी
不是一个字符,而是两个字符组合成一个字符:因此,在您的情况下,单词
प्रवीण
的长度不是 3,而是 6。输出将是
In the Hindi language, each character need not be of length one as is in English. For example,
वी
is not one character but rather two characters combined into one:So in your case, the word
प्रवीण
is not of length 3 but rather 6.And the output would be
编写与 Codeman 提供的伪代码相对应的工作 kotlin 代码。这可以帮助您获得以下两件事:-
我已经在这些输入上测试了此代码:-
这是我得到的输出:-
Writing working kotlin code corresponding to the pseudo code provided by Codeman. This can help you get these 2 things:-
I have tested this code on these inputs:-
This is the output that I am getting:-