我正在编写一个 Python 脚本来将文本文件解释为随机表,并在它们上滚动。当我在 Sublime Text 中运行该脚本时,它运行良好。例如,以下是 ST 中构建窗口的一些输出:
Getting random from 2500: Gold music box
Getting random from 2500: Eye patch with a mock eye set in blue sapphire and moonstone
Getting random from 2500: Fine gold chain set with a fire opal
Getting random from 2500: Embroidered silk adn velvet mantle set with numerous moonstones
Getting random from 2500: Gold music box
Getting random from H: Wand of the war mage, +3
Getting random from H: Weapon, +3
Getting random from H: Staff of frost
Getting random from CR 17 Hoard Items: Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
Getting random from CR 17 Hoard: 46000 gp, 34000 pp, and Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
46000 gp, 34000 pp, and Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
Number of arguments: 1 arguments.
Argument List: ['D:\\programming\\python-table-thing\\Table.py']
它也适用于 Windows 命令提示符:
D:\programming\python-table-thing>python Table.py
Getting random from 7500: Jeweled gold crown
Getting random from E: Potion of supreme healing
Getting random from E: Potion of storm giant strength
Getting random from 8: Animal Shapes
Getting random from E: Spell scroll (Animal Shapes)
Getting random from E: Universal solvent
Getting random from CR 17 Hoard Items: Jeweled gold crown, Spell scroll (Animal
Shapes), Potion of storm giant strength, Potion of supreme healing, Universal s
olvent
Getting random from CR 17 Hoard: 42000 gp, 24000 pp, and Jeweled gold crown, Spe
ll scroll (Animal Shapes), Potion of storm giant strength, Potion of supreme hea
ling, Universal solvent
42000 gp, 24000 pp, and Jeweled gold crown, Spell scroll (Animal Shapes), Potion
of storm giant strength, Potion of supreme healing, Universal solvent
Number of arguments: 1 arguments.
Argument List: ['Table.py']
但它在 Cygwin 中无法正常工作(使用 Mintty)。据我所知,在 Cygwin 中似乎在没有换行符的情况下在奇数位置插入回车,导致行的结尾覆盖了它的开头。
$ python Table.py
Getting random from 2500: Platinum bracelet set with a sapphire
Getting random from 2500: Jeweled anklet
Getting random from 2500:
Getting random from E: Potion of supreme healing
Getting random from E: Potion of supreme healing
Getting random from 8: Demiplane
)etting random from E: Spell scroll (Demiplane
Getting random from E: Arrow of slaying
Getting random from 9: Mass Heal
)etting random from E: Spell scroll (Mass Heal
, Arrow of slayingmiplanealingd Items: Platinum bracelet set with a sapphire
, Arrow of slayingmiplanealingd: 42000 gp, 28000 pp, and Platinum bracelet set with a sapphire
, Arrow of slayingmiplanealingum bracelet set with a sapphire
Number of arguments: 1 arguments.
Argument List: ['Table.py']
这也不仅仅是终端显示的问题。我尝试将其输出到文件中并得到相同的问题。
我假设这是 Cygwin 或 Mintty 的问题,但如果您认为它会有所帮助,这是我正在使用的源代码:http: //pastebin.com/4bJ4LC8h