Created
July 13, 2015 09:38
-
-
Save yfe404/2448890e164aadf48e26 to your computer and use it in GitHub Desktop.
Compte et affiche le nombre de lignes et de caractères dans une fichier.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Compte et affiche le nombre de lignes et de caractères dans une fichier. | |
# Usage : ./counter.py fichier | |
# author yann feunteun | |
# mail yannfeunteun at gmail dot com | |
from sys import argv | |
def main(): | |
nbLines = 0 | |
nbChar = 0 | |
input_file = file(argv[1]) | |
for line in input_file: | |
nbLines+= 1 | |
nbChar += len(line) | |
print ("Nombre de lignes {0}\nNombre de caracteres : {1}".format(nbLines, nbChar)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment