To compare the contents of two notepad and return 0 and 1

Asked 2 years ago, Updated 2 years ago, 15 views

[Notepad 1]

NtReadFile

SetFilePointer

NtClose

NtCreateFile

GetFileType

[Notepad 2]

NtCreateFile

GetFileType

NtAllocateVirtualMemory

GetFileInformationByHandle

RegOpenKeyExA

I read two notepads like this, and there are two overlapping words, so I want to return two 1 I don't know how to do it. Help me

python

2022-09-21 16:41

1 Answers

Please keep that in mind.

>>> f1 = open('/home/allinux/memo1.txt').read()splitlines()# Save list by line
['NtReadFile', 'SetFilePointer', 'NtClose', 'NtCreateFile', 'GetFileType']
>>> f2 = open('/home/allinux/memo2.txt').read().splitlines()
['NtCreateFile', 'GetFileType', 'NtAllocateVirtualMemory', 'GetFileInformationByHandle', 'RegOpenKeyExA']
>>> set(f1) & set(f2) # Intersection. Extract only the same ones
{'NtCreateFile', 'GetFileType'}
>>> len(set(f1) & set(f2))
2
>>> tuple(map(lambda i:1, set(f1) & set(f2)))
(1, 1)


2022-09-21 16:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.