# Display from nth line to mth line of a file
# Use command line arguments
import sys
fname = sys.argv[1]
fs = open(fname, "r")
stline = int(input("Enter starting line : "))
endline = int(input("Enter ending line : "))
L = fs.readlines()
print("File:", fs.name)
print("Lines from", stline, "to", endline)
for Line in L[(stline-1):endline]:
print(Line)
fs.close()
# Use command line arguments
import sys
fname = sys.argv[1]
fs = open(fname, "r")
stline = int(input("Enter starting line : "))
endline = int(input("Enter ending line : "))
L = fs.readlines()
print("File:", fs.name)
print("Lines from", stline, "to", endline)
for Line in L[(stline-1):endline]:
print(Line)
fs.close()
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu