Skip to content

Instantly share code, notes, and snippets.

@RaminNietzsche
Created April 18, 2017 14:23
Show Gist options
  • Select an option

  • Save RaminNietzsche/e6833c80cbc2db5bd849cb2effa15341 to your computer and use it in GitHub Desktop.

Select an option

Save RaminNietzsche/e6833c80cbc2db5bd849cb2effa15341 to your computer and use it in GitHub Desktop.
b.txt
patate : 21
ali : 22
patate javad : 21
alireza : 22
c.txt
javad : 21
ramin : 22
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