python中的Split函数,用于将句子中的单词分隔成一个列表
错误: “非类型”对象没有属性“低”python中的Split函数,用于将句子中的单词分隔成一个列表,python,python-3.x,split,Python,Python 3.x,Split,错误: “非类型”对象没有属性“低” 我希望它是非常基本的,我只希望这个句子变成一个单词列表。您假设print返回它正在打印的字符串,这不是真的,它不返回任何字符串(因为返回类型是空的)。调用print是因为写入stdout的副作用,而不是为了返回值 Sentence = print("Hello, i am the 14 year old creator of this program") MySentence = (Sentence.lower()) 从文字字符串转换为小写的字符串中创建一
我希望它是非常基本的,我只希望这个句子变成一个单词列表。您假设print返回它正在打印的字符串,这不是真的,它不返回任何字符串(因为返回类型是空的)。调用print是因为写入stdout的副作用,而不是为了返回值
Sentence = print("Hello, i am the 14 year old creator of this program")
MySentence = (Sentence.lower())
从文字字符串转换为小写的字符串中创建一个按空格分隔的字符串列表,然后打印列表的内容。打印用于在控制台中打印结果。您可以尝试:
words = "Hello, i am the 14 year old creator of this program".lower().split()
print(words)
非常感谢你。。。但我也需要知道如何分割句子
Sentence = "Hello, i am the 14 year old creator of this program"
MySentence = Sentence.lower()
print(MySentence)