Accès à un nom de fichier sélectionné par askopenfile
Bonjour à tous,
Je cherche à accèder à un nom de fichier avec tkinter (là je débute complet)
et la fonction askopenfiledialog.
Je souhaite récupérer uniquement la fin du nom de fichier du genre 17_06_2015__00_00.txt
voir l'exemple ci après.
Or la fonction renvoie je ne sais pas quoi mais comment y extraire la fin ??
Code:
1 2 3 4 5 6 7 8 9 10 11
| from tkinter import *
from tkinter.filedialog import *
from os import chdir
chdir ("S:\A SAUVER PYZO\ESSAIS\DATA VICTRON")
fenetre1=Tk()
fichier=askopenfile(parent=fenetre1,title="Selection d'un fichier")
fenetre1.mainloop()
print("Fichier choisi : ",fichier)
print ("c'est terminé") |
Voilà le résultat après sélection du fichier :
Code:
1 2 3
| In [19]: (executing lines 1 to 12 of "Exemple_tkinter_essai_ouverture_fichier_2.py")
Fichier choisi : <_io.TextIOWrapper name='S:/A SAUVER PYZO/ESSAIS/DATA VICTRON/17_06_2015__00_00.txt' mode='r' encoding='cp1252'>
c'est terminé |
Merci pour le coup de main.
P.G