二手产品经理

二手产品经理

THIS IS RENO

在线学Python100天 - 第四天

今天的学习比昨天来的更早一些。

学习记录

  1. 今天是对 print 和 input 的综合练习,编写了一个生成小故事的代码。
  2. 在 console 中居然能打印颜色,print 打印有点神奇。打印形式为:\033 [] m ,比如print("\033[31m")。有一点需要注意:打印颜色是一劳永逸的,如果用在突出重点之类的场景中。把文字改成红色之后,要再改为白色才能起到作用。

CODE

print("=== Your Adventure Simulator ===")
print("""You'll be asked a bunch of questions
then we'll make you up adn amazing
story with YOU as the star! 🌟""")
print()
name = input("Your name: ")
enemy = input("Your worst enemy's name: ")
superPower = input("Your super power: ")
print()
print("our story begins as our hero name approaches a foreboding castle...")
print("Suddenly a bolt of lightning striked the ground at the feet of", "\033[31m", name, "\033[0m")
print("'Our final battle begins!' shouts the evil", enemy, superPower, "which means they'll win quite easily") 
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。