![]() ![]() Although Windows prefers backslashes in its user interface, forward slashes work too, and they don't have special meaning in Python string literals. ![]() You can use forward slashes instead of backslashes. Then the string actually passed to os.startfile will not contain those backslashes it will contain a form-feed character (from the \f) and two backspace characters (from the \bs), which is not what you want at all. So if you take a Windows pathname and plug it into Python like this: os.startfile('C:\foo\bar\baz') Or if you want a newline character, you can do this: 'First line.\nSecond line.' For instance, if you are writing a single-quoted string and you want a single quote in it, you can do this: 'don\'t'. In a Python string literal, the backslash \ is used for putting things into the string that would otherwise be difficult to enter. In a Windows filesystem, the backslash \ is the standard way to separate directories. Did you put quotes around your pathname at all? If not, that will certainly not work - but once you do, you will find that then you need the rest of what I've written below. Or actually maybe it's something simpler. It's hard to be certain from your question as it stands, but I bet your problem is backslashes.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |