[PLUG] Python Lists and File Reads
Rich Shepard
rshepard at appl-ecosys.com
Sat Jul 16 00:01:21 UTC 2005
On Fri, 15 Jul 2005, Rich Shepard wrote:
> For example, I now have reworked the input data file so one term is on each
> line, and the script (still playing interactively), and read them into a
> list. But, each item in the list has a terminating \n and I don't know how to
> strip that off. Slicing removes the last element, not the newline from each
> element.
Got it!
fh = open('environ.in', 'r')
input = fh.read().split()
... and input is a list with no newlines.
Excelsior!
Rich
--
Dr. Richard B. Shepard, President | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
More information about the PLUG
mailing list