A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/1999-November/016266.html below:

Text Manipulation in Python

Text Manipulation in Python Text Manipulation in PythonWilliam Park parkw at better.net
Wed Nov 10 06:31:34 EST 1999
On Wed, Nov 10, 1999 at 08:46:42AM +0000, Edward Hasted wrote:
> I am completely new to Python.
> 
> We want to use it to alter specific lines in template files, typically 
> something like changing:-
> 
> Variable = 1234
> 
> to 
> 
> Variable = Company Name
> 
> The text manipulation strings within Python seem to work sequentially 
> rather than on a line basis.
> 
> 1. Is this correct?

Well, you have read line by line.  Try something like
    f = open(..., "r")
    for s in f.readlines():
	s = ...do string substitution using 're' or 'string' module...
	print s
But, if you're running Unix, you can also use 'sed'.

> 2. What is the best way to do text searching and manipulation within 
> Python.
> 
> Many thanks,
> 
> Edward 
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4