Currently, I have the following code...
file_name = content.split(\'=\')[1].replace(\'\"\', \'\') #file, gotten previously
fileName = \"/\" + self.feed + \"/\" +
This will create the file feed/address/file.txt
in the same directory as the current script:
import os
file_name = 'file.txt'
script_dir = os.path.dirname(os.path.abspath(__file__))
dest_dir = os.path.join(script_dir, 'feed', 'address')
try:
os.makedirs(dest_dir)
except OSError:
pass # already exists
path = os.path.join(dest_dir, file_name)
with open(path, 'wb') as stream:
stream.write('foo\n')