| 1 |
ninoborges |
8 |
|
| 2 |
|
|
|
| 3 |
|
|
import os
|
| 4 |
|
|
|
| 5 |
|
|
def CountLines(fileObj):
|
| 6 |
|
|
fileObj.seek(0)
|
| 7 |
|
|
contents = fileObj.readlines()
|
| 8 |
|
|
return len(contents)
|
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
def CountChars(fileObj):
|
| 12 |
|
|
fileObj.seek(0)
|
| 13 |
|
|
contents = fileObj.read()
|
| 14 |
|
|
return len(contents)
|
| 15 |
|
|
|
| 16 |
|
|
if __name__ == '__main__':
|
| 17 |
|
|
inputFile = open(r"C:\Documents and Settings\eaborges\Desktop\Working\readme.txt",'r')
|
| 18 |
|
|
numbLinesFound = CountLines(inputFile)
|
| 19 |
|
|
numbCharsFound = CountChars(inputFile)
|
| 20 |
|
|
print "This file contains %d lines and %d characters"% (numbLinesFound, numbCharsFound) |