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
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
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!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1291
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: 394
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!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1291
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: buran, Google [Bot], metulburr, Sleepisnotnecessary and 5 guests