Python Forum
How to receive two passed cmdline parameters and access them inside a Python script?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to receive two passed cmdline parameters and access them inside a Python script?
#3
For something this simple you can use sys.argv
import sys

print(sys.argv)
Output:
> python test.py "D:\tools\input data.txt" 65656 ['test.py', 'D:\\tools\\input data.txt', '65656']
Notice that 65656 is a str, not a number.
Reply


Messages In This Thread
RE: How to receive two passed cmdline parameters and access them inside a Python script? - by deanhystad - Feb-17-2024, 12:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Receive Input on Same Line? johnywhy 8 811 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,404 Jun-29-2023, 11:57 AM
Last Post: gologica
  How to continuously receive messages until specified to stop using Bleak jacobbreen25 3 2,218 Dec-28-2022, 04:25 PM
Last Post: jacobbreen25
  How can I add an end line character after every value that I receive? GiggsB 11 5,307 Mar-06-2022, 08:51 PM
Last Post: GiggsB
  mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python ilknurg 3 5,716 Jan-18-2022, 06:25 PM
Last Post: ilknurg
  How to receive webcam capture on spout? buzzdarkyear 2 2,692 Jan-12-2022, 02:26 PM
Last Post: buzzdarkyear
  detecting a generstor passed to a funtion Skaperen 9 3,727 Sep-23-2021, 01:29 AM
Last Post: Skaperen
  Automating to run python script 100 times by changing parameters pmt 1 2,629 Dec-29-2020, 10:31 AM
Last Post: andydoc
  how to modify a variable that is passed as parameter StefanL38 2 2,147 Dec-07-2020, 08:39 AM
Last Post: StefanL38
  Parameters aren't seen inside function Sancho_Pansa 8 2,979 Oct-27-2020, 07:52 AM
Last Post: Sancho_Pansa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020