我不知道 argv 是什么以及 raw_input() 有什么不同? [英] I Don't Know What is argv and what's different with raw_input()?

查看:23
本文介绍了我不知道 argv 是什么以及 raw_input() 有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Learn Python the Hard way"中学习 Python

I Learn Python From "Learn Python the Hard way"

我不知道argv是什么!!

I don't know what is argv !!

(请用例子和文字解释argv)

(please explain argv with Example and text)

问题 2:

raw_input & 有什么不同?argv ?

What is Different between raw_input & argv ?

推荐答案

argv 代表 argument value 代表参数从命令行启动时传递给您的程序.

argv stands for argument value and it represents the arguments passed to your program when it is launched from the command line.

例如,如果您的程序名为 example.py,并且您像这样运行它:

For example, if your program is called example.py, and you run it like this:

$example.py '你好'

那么argv就是hello.

raw_input 是一种提示用户输入的方法.基本上,它会停止程序,显示一些文本(作为提示,但这是可选的),并且只有在用户输入内容时才会继续.然后您可以存储用户输入的内容.

raw_input is a way to prompt the user for some input. Basically, it will stop the program, display some text (as a prompt, but this is optional) and only continue when the user enters something. You can then store what the user entered.

如果您有以下情况:

username = raw_input('Please enter your name: ')
print('Your name is: {}'.format(username))

你的程序会像这样运行:

Your program will run like this:

$ example.py
Please enter your name: Burhan
Your name is: Burhan

这篇关于我不知道 argv 是什么以及 raw_input() 有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆