在python中有没有一种方法可以将字符串分隔成单独的单词?

在python中有没有一种方法可以将字符串分隔成单独的单词?,python,Python,我正在尝试将一个长字符串拆分为不同的单词,并在同一行上以.1秒的延迟打印出来。您可以根据它们之间的间距进行拆分: from time import sleep string = "hello world" words = string.split(' ') # splits the string into parts divided by ' ' for w in words: print(w, end=' ') sleep(0.1) #delays for 0.1 second

我正在尝试将一个长字符串拆分为不同的单词,并在同一行上以.1秒的延迟打印出来。

您可以根据它们之间的间距进行拆分:

from time import sleep
string = "hello world"
words = string.split(' ') # splits the string into parts divided by ' '
for w in words:
    print(w, end=' ')
    sleep(0.1) #delays for 0.1 seconds

欢迎来到StackOverflow。请浏览SO帮助中心中的“如何提出好问题”。请描述到目前为止您尝试了什么,什么不起作用,以及所需的输出是什么。String
split
time
模块可帮助您实现这一点。到目前为止您尝试了什么?为了使所有内容保持一致,您需要在print语句之后应用
。i、 e.
打印(w),