简体   繁体   English

Python Shell中的文字位置

[英]Text Position In Python Shell

I'm looking to make a game in python's Shell. 我想在python的Shell中制作游戏。 However, when text is printed, it is printed at the bottom. 但是,在打印文本时,它会打印在底部。 Is there any code I can use to scroll it all to the top or indent it. 有什么我可以用来将其全部滚动到顶部或缩进的代码。 Please let me know! 请告诉我! I'll show an example of what I want to happen: 我将展示一个我想发生的事的例子:

The code sections are the Shell screens 代码部分是“外壳”屏幕

EDIT This 'Hello Welcome' is printed at the top of the Shell screen 编辑此“ Hello Welcome”打印在外壳屏幕的顶部

                        Hello                        
                       Welcome!

This is an example for a UI, the text is indented: 这是UI的示例,文本缩进:

            Money: $5

The text is indented 文字缩进

I also want to select a line to print the text eg: 我也想选择一行来打印文本,例如:

Line 1
Line 2
Line 3

print 'Hi' line 2

If anyone knows how to do this please let me know, I've looked for some time and haven't found any answer. 如果有人知道该怎么做,请告诉我,我找了一段时间,还没有找到任何答案。

  1. Use formatting for indentation 使用格式缩进

     print(' %s' % 'hello') >>> hello 
  2. The perfect solution and, as I know common for console apps: clean output and reprint it with updated state 完美的解决方案,并且据我所知,对于控制台应用程序很常见:清除输出并以更新的状态重新打印它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM