【发布时间】:2021-10-30 12:12:16
【问题描述】:
我有一个多行字符串
words = """anticipated, unlikely, preferable, accidental, haphazard result
team members, student, bride reluctant"""
最后一个单词与倒数第二个单词之间用制表符分隔,而不是逗号
即 "预期的,不太可能的,可取的,偶然的,偶然的\结果"
多行字符串中的每一行都有不同数量的单词
我想从每一行中打印出一个结果,其中最后一个单词与前面的每个单词组合在一起:
anticipated result
unlikely result
preferable result
accidental result
haphazard result
reluctant team members
reluctant students
reluctant bride
抱歉,在尝试了拆分和字典路径后,我无法想出任何代码。
【问题讨论】:
-
你尝试了什么?似乎是与字典无关的直接拆分