插入奇数回车的Cygwin在运行Python脚本时没有换行符

时间:2014-11-29 23:33:58

标签: python cygwin output carriage-return mintty

我正在编写一个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

0 个答案:

没有答案