17 lines
378 B
Python
17 lines
378 B
Python
#!/usr/bin/env python
|
|
|
|
import sys
|
|
|
|
filename = sys.argv[1]
|
|
|
|
with open(filename, "r") as fileobj:
|
|
max_linelength = 0
|
|
longest_line = -1
|
|
|
|
for i, line in enumerate(fileobj):
|
|
if len(line) > max_linelength:
|
|
max_linelength = len(line)
|
|
longest_line = i + 1
|
|
|
|
print(f"The longest line is line {longest_line} with a length of {max_linelength}.")
|