编写一个python程序,接受一系列空格分隔的单词作为输入,反转字符串中单词的顺序。
时间: 2023-05-27 21:03:43 浏览: 104
Python大作业之jmu-java&python-统计字符个数.txt
```python
s = input("请输入一些单词,单词之间用空格分隔:")
words = s.split()
reversed_words = list(reversed(words))
result = " ".join(reversed_words)
print("反转后的单词顺序为:", result)
```
输入:`hello world my name is John`
输出:`John is name my world hello`
阅读全文