Home arrow Python arrow Page 2 - Python: Stringing You Along

Making Text Appear Exactly As You Typed It - Python

If you have ever programmed before, or are a ninety-year-old lady, or a cat, then you know how useful strings are. If you have been reading these articles, you will know that a string is a character, a sentence, a paragraph, a book, etc. If you haven't been reading these articles, then you're missing an important part of your education as a programmer. Don't keep yourself in the dark; start reading!

TABLE OF CONTENTS:
  1. Python: Stringing You Along
  2. Making Text Appear Exactly As You Typed It
  3. Other Ways to Span Text
  4. String Operators
By: James Payne
Rating: starstarstarstarstar / 5
January 28, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement


#!/usr/local/bin/python

two_cities= """

  It was the best of times, it was the worst of times, it was the age of  wisdom,

it was the age of

     foolishness

it was the epoch of belief, it was the epoch of incredulity, it was the               season

     of Light, it was the season

           of Darkness,

it was the spring of hope, it was the winter of despair, we had everything

before us,

   we had nothing

before us,

  we were all going direct to heaven, we were all going direct the

other way-

in short, the period was so far like the present period, that some

  of its noisiest

authorities

insisted on its being received, for good or for evil, in the superlative

  degree

of comparison

  only.

"""

print "Look out! Dickens is back!"

print " "

print two_cities

The result of this code:

Look out! Dickens is back!

 

  It was the best of times, it was the worst of times, it was the age of wisdom,

it was the age of

     foolishness

it was the epoch of belief, it was the epoch of incredulity, it was the season

of Light, it was the                    season

                                of Darkness,

it was the spring of hope, it was the winter of despair, we had everything

  before us,

we had nothing

  before us,

we were all going direct to heaven, we were all going direct the

other way-

in short, the period was so far like the present period, that some

  of its noisiest

              authorities

insisted on its being received, for good or for evil, in the superlative

          degree

of comparison

         only.




 
 
>>> More Python Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: