如何获得连接词长度?

2024-10-03 15:29:37 发布

您现在位置:Python中文网/ 问答频道 /正文

join_word = ' '.join(word)
len_join_word = len(join_word)

我试着弄到一个单词的长度,但它什么也没印出来。你知道吗

有没有什么办法能让你得到连词的长度?你知道吗


Tags: len单词wordjoin办法连词
1条回答
网友
1楼 · 发布于 2024-10-03 15:29:37

你做得对:

In [1]: word=['a', 'sdfs', 'sdfsdfsfs']

In [2]: join_word = ' '.join(word)

In [3]: len_join_word = len(join_word)

In [4]: print(len_join_word)
16

I tried to get len of join_word but it print out nothing.

你可能什么都看不到,因为你没有打印结果。尝试在末尾添加print(len_join_word)。你知道吗

相关问题 更多 >