3

How can i apply raw string notation on input from the user? For exmple, i want to get path from the user and enforce raw string notation on it, so if the input is something like: "\path\the\user\chose" it will be accepted to the raw input / be converted later to r"\path\the\user\chose"

Liron Cohen
  • 321
  • 1
  • 3
  • 6
  • 7
    Raw string notation is only for _writing literals_ -- if you accept user input with backslashes in it, they will behave fine. No "conversion" is necessary. – tzaman Oct 14 '16 at 09:02
  • Possible duplicate of [What exactly do "u" and "r" string flags do in Python, and what are raw string literals?](http://stackoverflow.com/questions/2081640/what-exactly-do-u-and-r-string-flags-do-in-python-and-what-are-raw-string-l) – tzaman Oct 14 '16 at 09:03
  • @LironCohen Could you demonstrate how getting user input containing backslashes does *not* work? – Biffen Oct 14 '16 at 09:40

1 Answers1

1

I tried this path = input(r'Input your path:')

It seems that path is something like paht = \path\the\user\chose

By the way, I use Python3.

time Off
  • 21
  • 1