Mad Lib 生成器,字符串对齐

如何解决Mad Lib 生成器,字符串对齐

嗨,我正在尝试创建 Mad lib 生成器,但输出未正确对齐。任何人请帮助我。 我的代码

GirlsName=input("A girl's name :")
Number=input("A number :")
Emotion=input("An emotion :")
Place=input("A place :")
BoysName=input("A boy's Name :")
AnotherNumber=input("Another Number :")
NumLessFifty=input("A Number Less than 50 :")
MoreNumber=input("One more number :")
ReindeerName=input("A Reindeer's Name :")
AnotherEmotion=input("Another Emotion :")

Action=input("What you want to do build story or start over:")





if(Action=="build"):
###Mad Lib: The Christmas Surprise###

    print("STORY THE CHRISTMAS SURPRISE")

    Story="""{0}woke up one Christmas Day to find that she had no presents!
             On the end of her bed she found a letter from {1} of Santa's eleves.
             It said that Santa was very {2}.
             After she had read the letter,She found herself being whisked off to the {3}.
             There she met an elf whose name was {4}. He said that he was Santa's helper.
             Because Santa was happy,{0} had to deliver all {5} presents to everyone around the world before they woke up.
             {8} was in front and off they went.
             It was a hard job but in the end they did it in {6} minutes.
             When she arrived back home,she found {7} on her bed. She was so {9}."""

    newstring=Story.format(GirlsName,Number,Emotion,Place,BoysName,AnotherNumber,NumLessFifty,MoreNumber,ReindeerName,AnotherEmotion)
    print(newstring.rjust(10))

我得到的输出

圣诞惊喜的故事 莉莉在圣诞节那天醒来,​​发现她没有礼物! 在她的床尾,她发现了一封来自圣诞老人的两个小精灵的信。 它说圣诞老人很高兴。 看完信后,她发现自己被带到了公园。 在那里,她遇到了一个名叫约翰的精灵。他说他是圣诞老人的帮手。 因为圣诞老人很高兴,莉莉不得不在他们醒来之前将所有 37 份礼物分发给世界各地的每个人。 基拉在前面,他们走了。 这是一项艰苦的工作,但最终他们在 20 分钟内完成了。 当她回到家时,她在床上发现了 3 个。她好伤心。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?