[Débutant] askopenfilenames
Python 2.6
----------
Salut,
J'ai quelques problème avec askopenfilename et askopenfilenames.
Voici grosso-modo mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| ###########################################
import Tkinter
from tkFileDialog import askopenfilename
# Creation of a root window (hiden) parent of the open file dialog
root = Tkinter.Tk()
root.withdraw()
# Get the name of the input file
file_input_name = askopenfilename(parent=root, title='Open file', filetypes=[('txt files', '*.txt')])
# Destroy the parent window
root.destroy()
# Open the input file
file_input = open(file_input_name, 'r')
# etc...
################################################ |
Et j'obtiens le message d'erreur suivant:
Code:
IOError: [Errno 22] invalid mode ('r') or filename: u'{C:/Documents and Settings/Test.txt}'
C'est quoi u' ?
askopenfilename retourne la chaine suivante: {C:/Documents and Settings/Test.txt}
Faut-il enlever { et } avant de passer la chaine dans open???
Et comment faire dans ce cas pour traiter un tuple de chaine renvoyé par askopenfilenames?
Merci de votre aide.