[Tutor] how do I input " as part of a string?

Robert H. Haener IV humbolt at comcast.net
Fri Jul 13 18:35:12 CEST 2007


Tom Tucker wrote:
> Try escaping the quotes.
> 
>>>> f = open("data.ini","w")
>>>> f.write("my \"car\" has been a great one for me")
>>>> f.close()
> 
> ~ >cat data.ini
> my "car" has been a great one for me

Tom beat me to posting that, see here for more information on escape sequences in Python:

http://docs.python.org/ref/strings.html


-Robert


More information about the Tutor mailing list