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

相关推荐
CoderYanger2 分钟前
Java EE 进阶:5. Spring IoC&DI(第三弹):Spring DI
java·开发语言·spring boot·spring·面试·java-ee·mvc
梯度下降者3 分钟前
Python从0到100(三):Python中的变量介绍
python·作用域·变量·数据类型·计算机常识
用户360055579004 分钟前
Kestrel_VLLM - 26 · 发射空档三步曲:事件计时 → nsys → 判别实验
前端
AIFQuant7 分钟前
Python期货行情API接入:股指、黄金、原油多品种数据管道实战
开发语言·python·金融·区块链·量化开发
echome8888 分钟前
JavaScript async/await 错误处理:别让 Promise 静默失败
开发语言·前端·javascript·promise
一条泥憨鱼18 分钟前
【Kafka】零基础学习教程
java·分布式·学习·kafka
PedroQue9925 分钟前
v0.2.0 架构升级:class + reactive 重塑状态管理
前端·uni-app
鶴哥只手遮天25 分钟前
Angular 22 源码级深度解析-第 02 章 编译链路总览:从模板字符串到 `ɵɵ` 指令
前端·开源·angular.js
尘世中一位迷途小书童25 分钟前
别再堆万字 Prompt:用 Agent Skills 给团队写一个「前端 Review」Skill
前端·ai编程·cursor
威哥爱编程27 分钟前
Python 智能体开发实战 07:让它查课表它张口就编?给 Agent 接上真正能动手的工具
python·agent