Solve the problem that the list content cannot be displayed when using the jieba.cut function

When using the jieba.cut function, it returns agenerator instead of an ordinary list. A generator is an iterable object that allows you to get elements one by one instead of storing them all in memory at once. This helps reduce memory usage, especially when you're dealing with large amounts of text data. 

 Solution:

[w for w in raw_list] is a list comprehension in Python. It is used to iterate through each element in and put these elements into a new list. raw_listw

import jieba

raw_list = """《进击的巨人》是一部知名的日本漫画和动画作品,创作和原作为諫山創(Hajime Isayama)。故事发生在一个充满巨人的残酷世界中,下面是其剧情的简要介绍:
在一个高墙围城的未来世界,人类被超高大的巨人威胁着。城墙的内部,安全的区域,是人类唯一的避难所。故事的主要角色是艾伦·耶格尔(Eren Yeager)、三笠·阿克曼(Mikasa Ackerman)和阿尔敏·阿勒特(Armin Arlert),他们生活在城墙内,渴望去城墙外的世界。
一天,城墙内突然出现了一只巨人,破坏了城墙,导致巨大的混乱。艾伦的母亲在这次事件中不幸丧生。艾伦、三笠和阿尔敏决定加入调查兵团,一个致力于对抗巨人的组织。他们发誓要揭开巨人的秘密,并夺回失去的自由。
故事随着主要角色的成长和冒险,揭示了巨人的起源、城墙内外的政治阴谋、巨人的真相以及人类社会的腐败。同时,角色之间的复杂关系也成为故事的一个重要元素。经过激烈的战斗和内外困难,他们逐渐揭示了巨人的来历以及更大的威胁。
《进击的巨人》深受粉丝喜爱,不仅因为它充满了紧张和惊险的战斗,还因为它提出了许多深刻的哲学和伦理问题,涉及权力、自由、人性和道德。这使得它成为了一个令人思考的故事,不仅仅是一个动作冒险作品。"""

raw_list=jieba.cut(raw_list,cut_all=False)
# print(raw_list)
raw_list=[w for w in raw_list]

 This will print out the content:

Guess you like

Origin blog.csdn.net/m0_74053536/article/details/134171793