On 2/24/18 2:08 PM, Peng Yu wrote:
On Sat, Feb 24, 2018 at 12:45 PM, Wildman via Python-list
<python-list@python.org> wrote:
On Sat, 24 Feb 2018 11:41:32 -0600, Peng Yu wrote:

I would like to just get the escaped string without the single quotes.
Is there a way to do so? Thanks.

x='\n'
print repr(x)
'\n'
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
x='/n'
print(repr(x))
'/n'
print(repr(x).strip("'"))
/n
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
x='/n'
print repr(x)
'/n'
print repr(x).strip("'")
/n
I was looking for something builtin python. There is not such a builtin way?


Peng, your last three questions all make me wonder what larger problem you are working on.  These all sound like there might be an easier way.  Can you take a step back and tell us about the big picture?

--Ned.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to