5

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"

3
  • 8
    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. Commented Oct 14, 2016 at 9:02
  • Possible duplicate of What exactly do "u" and "r" string flags do in Python, and what are raw string literals? Commented Oct 14, 2016 at 9:03
  • @LironCohen Could you demonstrate how getting user input containing backslashes does not work? Commented Oct 14, 2016 at 9:40

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks bro, its really working for me, you saved my lot of time.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.