Help Me With This Python Code - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Me With This Python Code (687 Views)
| Help Me With This Python Code by Harkstetunz(op): 3:26pm On Dec 15, 2020 |
Hello Programlanders .I've been learning python for some time using 'Automate the boring stuff' ; I've been scaling through each topic successfully, not until I got to chapter 8 project where the knowledge of command line argument is to be employed in multiclipboard project. The problem is I don't seems to understand handling command line arguments, as much was not written about it in the book. I've watched some YouTube videos but it's the same old story. I'm using pycharm text editors. len(sys.argv)==3 and sys.argv[1].lower()=='save': for my program to work, the above condition must be true but my len(sys.argv) is always 1 thereby rendering my code useless. I will really appreciate it if you can help me out or better still recommend any book that comprehensively explains HANDLING COMMAND LINE ARGUMENTS in python Evilsec Ibromodzi Stanliwise |
| Re: Help Me With This Python Code by ibromodzi: 6:34pm On Dec 15, 2020 |
Harkstetunz:If len(sys.argv)is returning 1, it means you only have one argument in the program which is the filename (or the executable). sys.argvreturns a list with the first element being the filename followed by other arguments in the program. We'll be able to make significant contributions if you could share the whole code. Meanwhile, you can go through these links, I hope you find them useful; https://realpython.com/python-command-line-arguments/ https://www.youtube.com/watch?v=PZN7vVxeh9M&feature=youtu.be |
| Re: Help Me With This Python Code by valzey(m): 11:44pm On Dec 15, 2020 |
If you are using pycharm run, you need to set the arguments before running. However, you can simply 1. Go into the project folder 2. Open cmd or powershell in that folder (shift + right click) and select appropriately. 3. Run py [file].py arg1 arg2 |
| Re: Help Me With This Python Code by Harkstetunz(op): 8:10am On Dec 16, 2020 |
Wow! Thanks guys |
| Re: Help Me With This Python Code by cosmos2000(m): 7:26pm On Dec 25, 2020 |
Harkstetunz:What version of pycharm are you using...Mine is 2020.3 though I recently downloaded it..but the configuration is something else...can you help me wit it..? |
Can Someone Help With This Python Problems • Help With This Python Programming Assignment Please • I'm Getting An Error While I Run This Python Codes • 2 • 3 • 4
Hackers In The House. What Is The Biggest Hack You've Ever Pulled Off • Are You A Software Developer? Earn More As An Application Security Engineer • Thread removed or archived
.