获取一个文件并打乱中间的所有字母
我需要拿一个文件并打乱每个单词的中间字母,但我无法打乱第一个和最后一个字母,而且我只能打乱超过 3 个字符的单词。我想如果我可以将每个单词放入它们自己的单独列表中,其中所有字母都分开,我就可以找到一种方法来打乱它们。任何帮助将不胜感激。谢谢。
I need to take a file and shuffle the middles letters of each word but I can't shuffle the first and last letters, and I only shuffle words longer then 3 characters. I think I can figure out a way to shuffle them if I can put each word into their own separate list where all the letters are separated. Any help would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
故意不实现随机播放算法。
The shuffle algorithm is intentionally not implemented.
看看 random.shuffle。它将列表对象洗牌到适当的位置,这似乎就是您的目标。你可以做这样的事情来打乱字母
`
只要记住随机导入
Look at random.shuffle. It shuffles a list object in place which seems to be what youre aiming for. You can do something like this for shuffling the letters around
`
Just remember to import random