#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Unhappy How am i screwing this up ?


    code
    FilePath = "Z:\Python Projects\Tag Reader\"
    print FilePath
    testmp3 = "001- The Cowboys Email Order Bride - Chance Creek Book 1.mp3"
    print testmp3


    The error message I get is

    File "Z:\Python Projects\Test\__init__.py", line 5

    FilePath = "Z:\Python Projects\Tag Reader\"

    ^

    SyntaxError: EOL while scanning string literal
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    Python uses backslashes to start an escape sequence. So they don't work like "normal" characters. To get literal backslashes, you either need to put another backslash in front of each one, or you need to use "raw strings" (as explained in the link above).

    Or maybe you can get rid of the stupid Windows backslashes and replace them with Unix slashes.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0
    will unix style slashes work on a windows environment ? I did not think that they did.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,851
    Rep Power
    481
    Costs little to try the / slashes.
    Python might translate for you.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    194
    Rep Power
    2
    Originally Posted by 666JTK666
    will unix style slashes work on a windows environment ? I did not think that they did.
    While unix slashes should work without incident best practice would be to use os.path.join and avoid the issue altogether.

    -Mek

IMN logo majestic logo threadwatch logo seochat tools logo