Created
April 18, 2017 14:23
-
-
Save RaminNietzsche/e6833c80cbc2db5bd849cb2effa15341 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| b.txt | |
| patate : 21 | |
| ali : 22 |
This file contains hidden or 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
| patate javad : 21 | |
| alireza : 22 | |
| c.txt |
This file contains hidden or 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
| javad : 21 | |
| ramin : 22 |
This file contains hidden or 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
| import sys | |
| def ligne(texte): | |
| with open(texte) as ouvrir: | |
| lecture = ouvrir.readlines() | |
| result = [] | |
| for item in lecture: | |
| if item.strip().endswith('txt'): | |
| lecture.remove(item) | |
| result = ligne(item.strip()) | |
| words = [':'.join([x.strip() for x in line.split(':')]) for line in lecture] | |
| words = [x for x in words if len(x) > 1] | |
| return words + result | |
| return "Le fichier {} n'existe pas.".format(texte) | |
| def main(): | |
| while True: | |
| entree = sys.argv[1:] | |
| choix = str(entree) | |
| texte = "a.txt" | |
| if texte in choix: | |
| message4 = sorted(ligne(texte)) | |
| for i in message4: | |
| print(i) | |
| break | |
| else: | |
| print("Il faut préciser le nom du fichier à traiter") | |
| break | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment