笨方法学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 也会作为一个变量。

相关推荐
IT_陈寒4 小时前
为什么我的Vue组件总是莫名其妙重渲染?
前端·人工智能·后端
乘风gg5 小时前
企业级 AI Coding 的 Harness 工程实战:8 个 Skill 串起全链路
前端·ai编程·claude
alphaTao5 小时前
LeetCode 每日一题 2026/8/24-2026/8/30
python·算法·leetcode
lhldsg5 小时前
AI零售系统实战指南:从架构设计到落地部署全解析
java·人工智能·小程序·uni-app·零售
苏灿烤鱼5 小时前
当 AI Agent 遇见真实科学环境:深度拆解 Scientific Agent Skills,把"聊天机器人"变成"AI 科学家"
python·开源·agent
张文君5 小时前
ubuntu26.04坏道坏块分区隔离急速版260831-V0.12
linux·python
Interview Aid1125 小时前
TikTok OA 四题分享|半小时内 AC,题目基本都是实现题
java·开发语言·算法·面试·职场和发展
mldong5 小时前
换了工作流引擎,前端一行代码没改
java·架构
染指11106 小时前
103.RAG-LLamaIndex后端rag问答-聊天接口
前端·javascript·vue.js·人工智能
微尘寒风13 小时前
【Git】的安装和使用
java·git