Python Help ...
Bill Campbell
linux-sxs
Wed Mar 28 09:19:15 PDT 2007
On Wed, Mar 28, 2007, Michael Hipp wrote:
>Ben Duncan wrote:
>> Ok, I need to CREATE a "Character" array that is 132 characters wide and
>> 66 rows deep in Python. I need to stuff text strings into this array.
>>
>> How do I go about doing this ?
>
>myArray = [
> "ABCDEF...132", # 0
> #...
> "ABCDEF...132", # 131
>]
>
># --OR--
>
>myArray = []
>myArray.append("ABCDEF...132") # 0
>#...
>myArray.append("ABCDEF...132") # 131
>
>Course, you can always use some "for" loop.
>
>row = 65
>col = 132
>newChar = "X"
>myArray[col][row] = newChar
You don't necessarily need to have a doubly indexed array as
strings are automatically addressable as lists (immutable lists,
but lists anyway).
>>> s = '123'
>>> s[2]
'3'
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
Government is actually the worst failure of civilized man. There has
never been a really good one, and even those that are most tolerable
are arbitrary, cruel, grasping and unintelligent.
-- H. L. Mencken
More information about the Linux-users
mailing list