为什么输出中的字母之间有空格? [英] Why are there spaces between the letters in my output?

查看:716
本文介绍了为什么输出中的字母之间有空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面我要披露我写的剧本。我叫它 GhostWriter 。它应该写一个你键入的消息,好像鬼正在为你写它。它甚至有一些非常基本的AI来模拟真实的人打字。问题是,当它在python shell中运行时,它会在我的消息的字母之间放置空格。请提交一个版本,它将从ghost写入的消息中取出空格。 (是的,我是计算机编程的新手......所以不要批评我的蹩脚程序!)


展开 | 选择 | Wrap | 行号

解决方案

替换for循环中的最后一行(print x,)

with:

sys.stdout。 print(x)


*不要忘记导入sys;)


你想出的相当简洁的程序......不切实际但看起来很整洁。



替换for循环中的最后一行(print x,)

with:

sys.stdout.print(x)


*别忘了导入sys;)


你提出的相当简洁的程序......不切实际但很好看。



非常感谢您的帮助。我还在学习python的绳索,所以让有人知道他们在做什么是有帮助的。



替换for循环中的最后一行(print x,)

with:

sys.stdout.print(x)


*并且不要忘记导入sys;)


你想出的相当简洁的程序......不切实际但又很整洁。



呃,很抱歉再次给你发了个错误,但当我把 sys.stdout.print(x)时,它会出现无效的语法。如果有的话,给我发送你在程序中添加作为代码的代码,这样我就可以看到它是如何适合的。感谢


Below I am disclosing a script I wrote. I called it GhostWriter. It is supposed to write a message you type in as if a ghost were writing it for you. It even has some very basic AI to simulate a real person typing. The problem is, is that when it is run in the python shell, it puts spaces in between the letters of my message. Please submit a version of this that will take the spaces out of the Message being written by the ghost. (And yes, I am new to computer programming... so don''t criticize my lame program!)


Expand|Select|Wrap|Line Numbers

解决方案

Replace the last line in your for loop ( print x, )
with:
sys.stdout.print( x )

* And don''t forget to import sys ;)

Pretty neat program you came up with... impractical but neat to see.


Replace the last line in your for loop ( print x, )
with:
sys.stdout.print( x )

* And don''t forget to import sys ;)

Pretty neat program you came up with... impractical but neat to see.

Thanks so much for the help. I''m still learning the ropes as far as python goes, so it''s helpful to have someone who knows what they''re doing.


Replace the last line in your for loop ( print x, )
with:
sys.stdout.print( x )

* And don''t forget to import sys ;)

Pretty neat program you came up with... impractical but neat to see.

ehh, sorry to bug you again, but when I place sys.stdout.print(x) it comes up with invalid syntax. If anything, send me the code you added as code in the program, so I can see how it fits in there. Thanks


这篇关于为什么输出中的字母之间有空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆