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 some 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.
""")
要在命令框直接输入 python 文件名 变量名
不知道是否版本问题,变量名中感觉script是默认的可以不写
如程序保存为ex13.py 运行的时候直接输入
python ex13.py user_name
同时,命令行里的user_name可以用自己自定义的名称