1.将用户提示符设置为变量
promptfrom sys import argv
script,user_name = argvprompt = ‘> ’
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(f"What kind of computer do you have?")computer = input(prompt)
print(f""“Alringt, so you said {likes} about liking me.You live in {lives}. Not sure where that is.And you have a {computer} computer. Nice.”"")
输出为
Hi Crystal, I’m the ex1.py script.I’d like to ask you a few questions.Do you like me Crystal?> No.Where do you live Crystal?> CQWhat kind of computer do you have?> Not-too-bad
Alringt, so you said No. about liking me.You live in CQ. Not sure where that is.And you have a Not-too-bad computer. Nice.
笨办法Python3 14
最新推荐文章于 2020-02-23 17:27:48 发布