Reputation: 618
I am trying to open a file inside the two folders
import glob
import os
wPlayer = '1'
playeritems = 'PlayerFiles/PlayerItems'
with glob.glob(os.path.join(playeritems, open('inventory.%s.txt' % wPlayer, 'r'))) as wPs:
#do stuff with wPs
But it is giving me there error
There is no such file or directory: 'inventory.1.txt'
But I know for a fact that there is 'inventory.1.txt'
inside PlayerFiles/PlayerItems.
What am I doing wrong? Is it because it is a string?
I used this question to get where I am now.
Upvotes: 1
Views: 147
Reputation: 1137
If you have the path and the filename, as constructed with your join, what is glob
doing there? It looks like you're opening a single file.
import os
wPlayer = '1'
playeritems = 'PlayerFiles/PlayerItems'
with open(os.path.join(playeritems,'inventory.%s.txt' % wPlayer), 'r') as wPs:
#do stuff with wPs
Upvotes: 2