Python strings - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Python strings (/showthread.php?tid=145907) |
Python strings - emveepee - 2012-11-21 What is the correct form to create strings in python for use with Windows folders that have the backslash. I am testing with a folder like L:\2 Broke Girls and sending this to JSON API for VideoLibrary.Scan() It won't work because L:\2 shows as L:\u002 Broke Girls and it doesn't work with the double backslash either. I can manually cat two string 'L:\' + '2 Broke Girls' but that will could be a coding nightmare. Martin RE: Python strings - sphere - 2012-11-23 It should work with the double backslash. Code: >>> import os RE: Python strings - emveepee - 2012-11-23 Thanks for the reply. Maybe this is a JSON encoding thing, when it gets transfefred to a sqlite like statement it was failing. Martin Re: RE: Python strings - Martijn - 2012-11-23 (2012-11-23, 16:49)emveepee Wrote: Thanks for the reply. Maybe this is a JSON encoding thing, when it gets transfefred to a sqlite like statement it was failing. Before send in json .replace('\\','\\\\') RE: Python strings - emveepee - 2012-11-23 I will have to set up the test again, but I think when I tried escaping the backslash and it worked with \2 Broke Girls folder but I couldn't scan normal alpha folders. Martin |