473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Command line input

How do I receive input from the command line in Python?
Mar 31 '08 #1
5 1548
On Mon, 31 Mar 2008 12:39:54 -0700, hexusnexus wrote:
How do I receive input from the command line in Python?
Direct way `sys.argv`, comfortable way `optparse`.

Ciao,
Marc 'BlackJack' Rintsch
Mar 31 '08 #2
On 31 Mar 2008 20:13:05 GMT, Marc 'BlackJack' Rintsch <bj****@gmx.netwrote:
On Mon, 31 Mar 2008 12:39:54 -0700, hexusnexus wrote:
>How do I receive input from the command line in Python?

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

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se R'lyeh wgah'nagl fhtagn!
Mar 31 '08 #3
On Mar 31, 2:39 pm, hexusne...@gmail.com wrote:
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? ")
What is your name? Rick <ENTER>
>>my_name
'Rick'

Mar 31 '08 #4
On Mar 31, 4:04 pm, Rick Dooling <rpdool...@gmail.comwrote:
On Mar 31, 2:39 pm, hexusne...@gmail.com wrote:
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? ")
What is your name? Rick <ENTER>>>my_name

'Rick'
Yeah, sorry for being vague. Thanks.
Apr 1 '08 #5

On Mon, 2008-03-31 at 12:39 -0700, he********@gmail.com wrote:
How do I receive input from the command line in Python?
I have used:

sys.argv[ 1 ]

I have been doing Python for around 2 days now, so please do double check that!

--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/p...disclaimer.htm

Apr 1 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert | last post by:
I am using the php4-cgi Debian package which is based on PHP 4.3.4. I have problems when running php4 on the command line. If I say something like $ php4 index.cgi a number of variables...
13
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is...
2
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain...
7
by: David A. Osborn | last post by:
I am current writing a console program that takes two file paths as command line input. I get the command line input using the following code: parameter = Split(Command()) input = parameter(0)...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
34
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: ...
6
by: evantri | last post by:
I am developing a program that prompt the input from the command line argument. For example, this is the lists of command line arguments that I want to include: -fish -cat -dog -animal All...
2
by: explode | last post by:
I made nova oledbdataadapter select update insert and delete command and connection veza. dataset is Studenti1data, I made it by the new data source wizard,and made datagridview and bindingsource...
11
by: Jon Davis | last post by:
Does anyone know why using System.Diagnostics.Process to "wrap" a console application does not always transmit the I/O, depending on what processes you're trying to "consume"? PowerShell, for...
4
by: Keith Hughitt | last post by:
Hi all, I am using someone else's script which expects input in the form of: ./script.py <arg1arg2 I was wondering if the angle-brackets here have a special meaning? It seems like they...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.