笨办法学python3 14. 提示和传递 input 和 argv 一起使用

14. 提示和传递

使用 input 和 argv 一起向用户提一些特别的问题

from  sys import argv

script, user_name = argv
prompt = "> "

print(f"Hi{user_name},I'm the {script} script.")
print("I'd like to ask you a few questions.")
print(f"Do you like me {user_name}")
likes = input(prompt)

print(f"Where do you live {user_name} ?")
lives = input(prompt)

print("What kind of computer do you have?")
computer = input(prompt)

print(f"""
Alright, so you said {likes} about liking me.
you live in {lives}. Not sure where that is.
And you have a {computer} computer. Nice.
""")

应该看到的结果:

发布了56 篇原创文章 · 获赞 17 · 访问量 2171

猜你喜欢

转载自blog.csdn.net/LanlanDeming/article/details/103337466