How do I Print the " character?

This is the place for queries that don't fit in any of the other categories.

How do I Print the " character?

Postby Hissing Cockroach » Mon Sep 30, 2013 8:31 pm

I have really been wondering how to print the " character
in python.I have looked up how to do this everywhere
and have found no answer. Does anyone else know?
User avatar
Hissing Cockroach
 
Posts: 108
Joined: Sat Sep 14, 2013 2:35 pm

Re: How do I Print the " character?

Postby metulburr » Mon Sep 30, 2013 8:34 pm

you use an escape sequence
Code: Select all
\"
we will be moving to python-forum.io on October 1 2016
more details here
User avatar
metulburr
 
Posts: 2243
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: How do I Print the " character?

Postby micseydel » Mon Sep 30, 2013 8:55 pm

Code: Select all
>>> print "\""
"
>>> print '"'
"

I would typically prefer the latter.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
micseydel
 
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: How do I Print the " character?

Postby Hissing Cockroach » Mon Sep 30, 2013 9:32 pm

Thanks! It's finally not bothering me anymore!
User avatar
Hissing Cockroach
 
Posts: 108
Joined: Sat Sep 14, 2013 2:35 pm

Re: How do I Print the " character?

Postby Kebap » Tue Oct 01, 2013 9:08 am

I agree with micseydel, but like ASCII too:

Code: Select all
>>> print ord('"')
34
>>> print chr(34)
"
New Users, Read These Hints

Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 689
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: How do I Print the " character?

Postby micseydel » Tue Oct 01, 2013 5:15 pm

Kebap wrote:I agree with micseydel, but like ASCII too:

Code: Select all
>>> print ord('"')
34
>>> print chr(34)
"

Typically people want to embed it in another string, not just print it ;)
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
micseydel
 
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 10 guests