I am trying to make a social program where the profiles are stored in .txt files here is part of the code:
XX = []
pl = glob.glob(\'*.txt\')
for a in pl:
if
The open method opens the file and returns a TextIOWrapper object but does not read the files content.
To actually get the content of the file, you need to call the read method on that object, like so:
G = open(P, 'r')
print(G.read())
However, you should take care of closing the file by either calling the close method on the file object or using the with open(...) syntax which will ensure the file is properly closed, like so:
with open(P, 'r') as G:
print(G.read())