I want to take multiple files one by one into python script as input files and perform my script operations on all of those files one after another.I want to do this using sys.argv list but don't know how to do this properly. here is the piece of code I have:
import re
r=open('sys.argv[1]',"r")
What am I supposed to do first to initialize this list and then open them one by one to read by my script? Any help will be obliged. thanks
If you need to use them one by one from command, you may use sys.argv[1:]
import sys
def main():
for filename in sys.argv[1:]:
with open(filename, 'r') as file:
file.readlines()
if __name__ == '__main__':
main()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With