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
Location: Earth

Re: How do I Print the " character?

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

you use an escape sequence
Code: Select all
\"
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1103
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.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 929
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
Location: Earth

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)
"
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: 282
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 ;)
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 929
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 5 guests