Frage wegen Stringübergabe

Hallo,
habe folgende Frage. Kann ich "re.search" nicht ein Stringarray übergeben? Führt immer zum Fehler!! Ich möchte einfach nur aus eine Textdatei nach einem Textmuster suchen..... (Zeilenweise)
Warum kann dies nicht ausgeführt werden? Ist nicht das komplette Proggi.
Vielen Dank für Eure Hilfe
Andreas
import sys import re import string
array = [1234, 4567]
src=open("xxx.txt", "r") srclines= src.readlines() src.close()
for line in srclines: if re.search(arry[i], line): ^^^^ stößt auf Probleme
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Andreas Protze wrote:
array = [1234, 4567] for line in srclines: if re.search(arry[i], line):
Dein Beispiel ist ein bischen durcheinander, so daß man schwer antworten kann. arry soll wohl array heißen und enthält überhaupt keine Strings?
Erzähl' doch mal genauer was du konzeptionell vorhast, dann kann man besser 'ne Lösung vorschlagen.
Gruß, Achim
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

--On Donnerstag, 20. Januar 2005 17:35 Uhr +0100 Andreas Protze Andreas.Protze@Wolfsburg.de wrote:
Hallo,
habe folgende Frage. Kann ich "re.search" nicht ein Stringarray übergeben? Führt immer zum Fehler!! Ich möchte einfach nur aus eine Textdatei nach einem Textmuster suchen..... (Zeilenweise)
Lesen bildet. Die API Dokumentation re.search() sagt nichts über Listen oder Arrays sondern redet lediglich von re.search(pattern, string). Wie kommst Du also auf ein Array??
-aj
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Hallo Andreas,
ganz einfach dein array enthält keine Strings. Versuchs mal so:
array = ["1234", "4567"]
Gruß
Fritz
On Thu, 20 Jan 2005 17:35:03 +0100 Andreas Protze Andreas.Protze@Wolfsburg.de wrote:
Hallo,
habe folgende Frage. Kann ich "re.search" nicht ein Stringarray übergeben? Führt immer zum Fehler!! Ich möchte einfach nur aus eine Textdatei nach einem Textmuster suchen..... (Zeilenweise)
Warum kann dies nicht ausgeführt werden? Ist nicht das komplette
Proggi.
Vielen Dank für Eure Hilfe
Andreas
import sys import re import string
array = [1234, 4567]
src=open("xxx.txt", "r") srclines= src.readlines() src.close()
for line in srclines: if re.search(arry[i], line): ^^^^ stößt auf Probleme
python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Hallo Fritz,
vielen Dank.... Treffer:-)
Andreas
Fritz Cizmarov wrote:
Hallo Andreas,
ganz einfach dein array enthält keine Strings. Versuchs mal so:
array = ["1234", "4567"]
Gruß
Fritz
On Thu, 20 Jan 2005 17:35:03 +0100 Andreas Protze Andreas.Protze@Wolfsburg.de wrote:
Hallo,
habe folgende Frage. Kann ich "re.search" nicht ein Stringarray übergeben? Führt immer zum Fehler!! Ich möchte einfach nur aus eine Textdatei nach einem Textmuster suchen..... (Zeilenweise)
Warum kann dies nicht ausgeführt werden? Ist nicht das komplette
Proggi.
Vielen Dank für Eure Hilfe
Andreas
import sys import re import string
array = [1234, 4567]
src=open("xxx.txt", "r") srclines= src.readlines() src.close()
for line in srclines: if re.search(arry[i], line): ^^^^ stößt auf Probleme
python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
participants (4)
-
Achim Domma (Procoders)
-
Andreas Jung
-
Andreas Protze
-
Fritz Cizmarov