Automatically Open Files Given As Command Line Arguments In Python
I have a lot of Perl scripts that looks something like the following. What it does is that it will automatically open any file given as a command line argument and in this case pri
Solution 1:
The fileinput module in Python's standard library is designed exactly for this purpose, and I quote a bit of code from the URL I just gave:
import fileinput
for line in fileinput.input():
process(line)
Use print
in lieu of process
and you have the exact equivalent of your Perl code.
Post a Comment for "Automatically Open Files Given As Command Line Arguments In Python"