我的.txt文件包含用“-”连字的单词(所有两个或三个音节的单词,每个单词在.txt文件的新行上)。我在寻找一种方法,把这个'-'的位置随机地移到左边或右边。这是将每个单词作为音节列表返回的代码:
for thisTrial in trials:
wordList = thisTrial['word'].split("-")
print wordList
例如,返回:
['ward', 'robe']
['dent', 'ist']
...
但我想要的结果是:
['war', 'drobe'] or ['wardr', 'obe']
['den', 'tist'] or ['denti', 'st']
...
关于如何得到这个结果有什么想法吗?你知道吗
如果每个单词只有一个连字符
或者你不再关心连字符了,只想随意地拨出一些单词。你知道吗
关于:
相关问题 更多 >
编程相关推荐