I would like to ask, how to use print()
in python3 to print the double quote (compulsory).
The code:
>>> List0 = ["1", "text", 25]
>>> print(List0)
['1', 'text', 25]
>>> str0 = str(List0)
>>> print(str0)
['1', 'text', 25]
str0
looks like a list but it is a string. Using print()
, the double quotes are not shown. How to use the print()
, but let the quotes shown? It should be like: "['1', 'text', 25]"
?
Thanks for the help!
It looks like you want to print what the string would look like if you were to assign it as a literal. For that, use repr
, like this:
print(repr(str0))
will print
"['1', 'text', 25]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With