Command line input

M

Marc 'BlackJack' Rintsch

How do I receive input from the command line in Python?

Direct way `sys.argv`, comfortable way `optparse`.

Ciao,
Marc 'BlackJack' Rintsch
 
J

Jorgen Grahn

Direct way `sys.argv`, comfortable way `optparse`.

I have a feeling he doesn't mean command-line arguments to the
program, but typing on the keyboard after the program has started.
If that is the case:

Direct way `sys.stdin`, many other fancy ways.

/Jorgen
 
R

Rick Dooling

How do I receive input from the command line in Python?

As long as we are all guessing, do you perhaps mean raw_input?

my_name = raw_input("What is your name? ")
'Rick'
 
H

hexusnexus

As long as we are all guessing, do you perhaps mean raw_input?

my_name = raw_input("What is your name? ")
What is your name? Rick <ENTER>>>> my_name

'Rick'

Yeah, sorry for being vague. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top