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

相关推荐
悟忧16 分钟前
规避ProseMirror React渲染差异带来的BUG
前端
No0d1es19 分钟前
电子学会青少年软件编程(C/C++)1级等级考试真题试卷(2025年9月)
java·c语言·c++·青少年编程·电子学会·真题·一级
小皮虾23 分钟前
小程序云开发有类似 uniCloud 云对象的方案吗?有的兄弟,有的!
前端·javascript·小程序·云开发
Android疑难杂症26 分钟前
鸿蒙Notification Kit通知服务开发快速指南
android·前端·harmonyos
T___T26 分钟前
全方位解释 JavaScript 执行机制(从底层到实战)
前端·面试
NewsMash32 分钟前
PyTorch之父发离职长文,告别Meta
人工智能·pytorch·python
阳懿32 分钟前
meta-llama-3-8B下载失败解决。
前端·javascript·html
Qinana33 分钟前
🌊 深入理解 CSS:从选择器到层叠的艺术
前端·css·程序员
IT_陈寒33 分钟前
Python 3.12新特性实测:10个让你的代码提速30%的隐藏技巧 🚀
前端·人工智能·后端
闲人编程39 分钟前
从零开发一个简单的Web爬虫(使用Requests和BeautifulSoup)
前端·爬虫·beautifulsoup·bs4·web·request·codecapsule