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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.