How should this function be changed to return \"123456\"
?
def f():
s = \"\"\"123
456\"\"\"
return s
UPDATE: Everyo
My guess is:
def f():
s = """123
456"""
return u'123456'
Minimum change and does what is asked for.
Maybe I'm missing something obvious but what about this:
def f():
s = """123456"""
return s
or simply this:
def f():
s = "123456"
return s
or even simpler:
def f():
return "123456"
If that doesn't answer your question, then please clarify what the question is about.
def f():
s = """123\
456"""
return s
Don't indent any of the blockquote lines after the first line; end every line except the last with a backslash.
re.sub('\D+', '', s)
will return a string, if you want an integer, convert this string with int
.
textwrap.dedent("""\
123
456""")
From the standard library. First "\" is necessary because this function works by removing the common leading whitespace.
Subsequent strings are concatenated, so you can use:
def f():
s = ("123"
"456")
return s
This will allow you to keep indention as you like.