How to read a directory whose name has characters like "/" in python?

I am working on OSX 10.5.8, which even allows you to specify "/" file names.

I have wx.TextCtrl containing a directory for reading (a catalog of music artists), there are groups called such

  • // Tense //
  • /// ▲▲▲ \\

so in the text box I write the directory name written as follows

/Users/....../Music/iTunes/iTunes Music////▲▲▲\\\/Untitled/ 

Of course, I get an error when reading, because the program does not recognize the group name and slashes, how can I solve it?

+4
source share
2 answers

Try replacing the / characters with file names (not directory names) with :

+2
source

I would recommend using wxPython built-in widgets like wx.FileDialog or filebrowsebutton

Here is a simple example that allows you to select multiple files:

 def onOpenFile(self, event): """ Create and show the Open FileDialog """ dlg = wx.FileDialog( self, message="Choose a file", defaultDir=self.currentDirectory, defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: paths = dlg.GetPaths() print "You chose the following file(s):" for path in paths: print path dlg.Destroy() 

I would recommend downloading the wxPython demo to check out its example of this widget and the other one I mentioned.

0
source

All Articles