Ich habe zwei Textdateien, Datei 1 ist eine Liste von Namen von Maschen mit einem Pfad. Manchmal ist der Name der gleiche Pfadname und kann Zahlen enthalten. Die Zeilen haben immer staticMesh = staticMesh'Replaceword '
Ich habe ein Python -Skript, aber ich erhalte einen weiteren Fehler. Außerdem möchte ich in eine Datei schreiben < /p>
Traceback (most recent call last):
File "C:\Users\TUFGAMING\Desktop\python\main.py", line 32, in
main()
File "C:\Users\TUFGAMING\Desktop\python\main.py", line 20, in main
quoted_word = match.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
< /code>
Hier ist ein Beispiel des Datenblocks < /p>
(Datei 1) < /p>
Dog /Game/Meshes/Bulldog
Fish /Game/Meshes/Goldfish
Cat /Game/Meshes/Cat
< /code>
(Datei 2) < /p>
Begin Map
Begin Level
Begin Map
Begin Level
Begin Actor Class=StaticMeshActor Name=Dog Archetype=StaticMeshActor'/Script/Engine.Default__StaticMeshActor'
Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0 ObjName=StaticMeshComponent0 Archetype=StaticMeshComponent'/Script/Engine.Default__StaticMeshActor:StaticMeshComponent0'
End Object
Begin Object Name=StaticMeshComponent0
StaticMesh=StaticMesh'Dog.Dog'
RelativeLocation=(X=-80703.9,Y=-91867.0,Z=7863.95)
RelativeScale3D=(X=1.0,Y=1.0,Z=1.0)
RelativeRotation=(Pitch=0.0,Yaw=-169.023,Roll=0.0)
End Object
StaticMeshComponent='StaticMeshComponent0'
RootComponent='StaticMeshComponent0'
ActorLabel="Dog"
End Actor
End Level
Begin Surface
End Surface
End Map
< /code>
(Ergebnis) < /p>
StaticMesh=StaticMesh'/Game/Meshes/Bulldog'
StaticMesh=StaticMesh'/Game/Meshes/Goldfish'
StaticMesh=StaticMesh'/Game/Meshes/Cat'
< /code>
import re
def main():
file_one = 'file-1.txt'
file_two = 'file-2.txt'
# holds (firstword, secondline)
word_tuples = []
with open(file_one, 'r') as file:
for line in file:
words = line.split() # splits on white space
word_tuples.append((words[0], words[1]))
with open(file_two, 'r') as file:
for line in file:
# extract content between the single quotes
match = re.search(r"StaticMesh=?'(.+)'", line)
quoted_word = match.group(1)
# see if any of the lines from file 1 match it
for word_tuple in word_tuples:
if word_tuple[0] == quoted_word:
print("MATCH FOUND")
print(f"file1: {word_tuple[0]} {word_tuple[1]}")
print(f"file2: {line.strip()}")
print(f"file3: {line}".replace(quoted_word, word_tuple[1]))
if __name__ == '__main__':
main()
Ich habe zwei Textdateien, Datei 1 ist eine Liste von Namen von Maschen mit einem Pfad. Manchmal ist der Name der gleiche Pfadname und kann Zahlen enthalten. Die Zeilen haben immer staticMesh = staticMesh'Replaceword ' Ich habe ein Python -Skript, aber ich erhalte einen weiteren Fehler. Außerdem möchte ich in eine Datei schreiben < /p> [code]Traceback (most recent call last): File "C:\Users\TUFGAMING\Desktop\python\main.py", line 32, in main() File "C:\Users\TUFGAMING\Desktop\python\main.py", line 20, in main quoted_word = match.group(1) AttributeError: 'NoneType' object has no attribute 'group' < /code> Hier ist ein Beispiel des Datenblocks < /p> (Datei 1) < /p> Dog /Game/Meshes/Bulldog
Fish /Game/Meshes/Goldfish
Cat /Game/Meshes/Cat < /code> (Datei 2) < /p> Begin Map Begin Level
Begin Map Begin Level Begin Actor Class=StaticMeshActor Name=Dog Archetype=StaticMeshActor'/Script/Engine.Default__StaticMeshActor' Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0 ObjName=StaticMeshComponent0 Archetype=StaticMeshComponent'/Script/Engine.Default__StaticMeshActor:StaticMeshComponent0' End Object Begin Object Name=StaticMeshComponent0 StaticMesh=StaticMesh'Dog.Dog' RelativeLocation=(X=-80703.9,Y=-91867.0,Z=7863.95) RelativeScale3D=(X=1.0,Y=1.0,Z=1.0) RelativeRotation=(Pitch=0.0,Yaw=-169.023,Roll=0.0) End Object StaticMeshComponent='StaticMeshComponent0' RootComponent='StaticMeshComponent0' ActorLabel="Dog" End Actor End Level Begin Surface End Surface End Map < /code> (Ergebnis) < /p> StaticMesh=StaticMesh'/Game/Meshes/Bulldog'
StaticMesh=StaticMesh'/Game/Meshes/Goldfish'
StaticMesh=StaticMesh'/Game/Meshes/Cat' < /code> import re
with open(file_one, 'r') as file: for line in file: words = line.split() # splits on white space word_tuples.append((words[0], words[1]))
with open(file_two, 'r') as file: for line in file: # extract content between the single quotes match = re.search(r"StaticMesh=?'(.+)'", line) quoted_word = match.group(1)
# see if any of the lines from file 1 match it for word_tuple in word_tuples: if word_tuple[0] == quoted_word: print("MATCH FOUND") print(f"file1: {word_tuple[0]} {word_tuple[1]}") print(f"file2: {line.strip()}") print(f"file3: {line}".replace(quoted_word, word_tuple[1]))
Ich habe ein Python -Skript mit dem Namen main.py , das im Grunde das Mikrofon des Benutzers verwendet, Befehle erkennt und eine Aufgabe ausführt. Wenn ich Hallo sage, wird das Skript verarbeitet,...
Ich versuche, eine CSV -Datei aus einem GCS -Bucket zu lesen, bestätigt, ob die Datei basierend auf einer Bedingung basiert, und schreibt dann eine gültige Datei in einen GCS -Ordner und eine...
Ich versuche, eine CSV -Datei aus einem GCS -Bucket zu lesen, bestätigt, ob die Datei basierend auf einer Bedingung basiert, und schreibt dann eine gültige Datei in einen GCS -Ordner und eine...
Ich habe vier Domains - Domain.com, Domain.org, Domain.africa und Domain.net. Alle teilen die gleiche Benutzerbasis von DB und einigen Inhalten. Benutzer können sich registrieren und sich auf jeder...