-1

When i write the following line of code

filename = 'E:\project\genres\blues\blues.00000.au'

I get the output as

'E:\\project\\genres\x08lues\x08lues.00000.au'

Why is 'b' from blues replaced by x08? And how can I solve this problem?

Becky
  • 191
  • 1
  • 1
  • 10

1 Answers1

1

\b is interpreted as backspace (much like \n is new line and \t is tab). See list of ASCII control characters. \x08 is the unicode representation of \b.

You need to either:

  • Use double slashes

    filename = 'E:\\project\\genres\\blues\\blues.00000.au'
    
  • Use forward slashes (Yes, these work on Windows)

    filename = 'E:/project/genres/blues/blues.00000.au'
    
  • Use a raw-string literal

    filename = r'E:\project\genres\blues\blues.00000.au'
    
DeepSpace
  • 78,697
  • 11
  • 109
  • 154
  • Kudos for the quick and rather complete answer; but really, please try to avoid answering questions which are obvious duplicates. We get this on a more or less daily basis. – tripleee Dec 31 '18 at 12:05