PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 25, 2022

[FIXED] What does it mean to call a module with parameters "python mymod.py 50"?

 November 25, 2022     module, python     No comments   

Issue

What does it mean to call a module with parameters python mymod.py 50?

What does it mean and what will happen?


Solution

It simply means you pass 50 as string parameter to the python script mymod.py.

Below is a sample code of mymod.py to show what will happen.

import sys

print("Hello World")

print(sys.argv)

if len(sys.argv) > 1:
    print(sys.argv[1])

You could copy this code snippet into mymod.py and test in your PC by running

python mymod.py 50

and you may get result like the following:

Hello World
['test.py', '50']
50

As a result, in mymod.py we could get the passed parameter from the built-in sys.argv var.

Hope it helps.



Answered By - Jack Smith
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing