"EOL while scanning single-quoted string", what is the meaning?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • excite
    New Member
    • Oct 2006
    • 5

    "EOL while scanning single-quoted string", what is the meaning?

    I am trying to write a long string into a txt file, the string includes some backslash, looks like:
    'd:\#########\# ######\####### d:\######\####\ ####\### d:\###\###\'
    then I got a error saying 'EOL while scanning single-quoted string'. But it works when I just delete the last backslash or add one more backslash in the end.
    Can someone tell me what is the meaning of this error, and how to handle this problem? Thanks.
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by excite
    I am trying to write a long string into a txt file, the string includes some backslash, looks like:
    'd:\#########\# ######\####### d:\######\####\ ####\### d:\###\###\'
    then I got a error saying 'EOL while scanning single-quoted string'. But it works when I just delete the last backslash or add one more backslash in the end.
    Can someone tell me what is the meaning of this error, and how to handle this problem? Thanks.
    Try this:
    Code:
    >>> s = 'd:\\#########\\#######\\####### d:\\######\\####\\####\\### d:\\###\\###\\'
    >>> print s
    d:\#########\#######\####### d:\######\####\####\### d:\###\###\

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by excite
      I am trying to write a long string into a txt file, the string includes some backslash, looks like:
      'd:\#########\# ######\####### d:\######\####\ ####\### d:\###\###\'
      then I got a error saying 'EOL while scanning single-quoted string'. But it works when I just delete the last backslash or add one more backslash in the end.
      Can someone tell me what is the meaning of this error, and how to handle this problem? Thanks.
      or use
      r'd:\#########\ #######\####### d:\######\####\ ####\### d:\###\###\'
      for raw string which works for windows dirictory.

      Comment

      Working...