Cygwin在运行Python scrip时插入奇数回车,不带换行符

2024-04-27 16:26:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个Python脚本,将文本文件解释为随机表,并对其进行滚动。当我从崇高的文本中运行脚本时,它的工作效果非常好。例如,以下是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命令提示符下工作:

^{pr2}$

但它在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


Tags: andoffromboxwithmusicrandommock