笨方法学python -练习14

程序:

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.

""")

我有一个误区,程序运行的时候我以为要运行两个参数 python .\ex14.py 2 3,其中2和3是我要输入的参数,结果发现显示报错。

我改成python .\ex14.py 2 就可以,原来.\ex14.py 也会作为一个变量。

相关推荐
崔庆才丨静觅6 小时前
hCaptcha 验证码图像识别 API 对接教程
前端
曹牧6 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
passerby60617 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了7 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅7 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
ValhallaCoder7 小时前
hot100-二叉树I
数据结构·python·算法·二叉树
崔庆才丨静觅7 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
爬山算法7 小时前
Hibernate(90)如何在故障注入测试中使用Hibernate?
java·后端·hibernate
kfyty7257 小时前
集成 spring-ai 2.x 实践中遇到的一些问题及解决方案
java·人工智能·spring-ai
猫头虎7 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven