Skip to content

Instantly share code, notes, and snippets.

@craigboman
Created August 24, 2018 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigboman/c96b5c652613d87f606a057a826030c9 to your computer and use it in GitHub Desktop.
Save craigboman/c96b5c652613d87f606a057a826030c9 to your computer and use it in GitHub Desktop.
describes a file read/write error in python
pth= '../json/'
#failed attempt to split out base filename: base = os.path.splitext(filename)[0]
merge = os.path.join(pth, Path(filename).stem)
with open(merge, 'w') as f:
json.dump(words, f, ensure_ascii=False)
f.close()
jsn = merge+'.json'
os.rename(merge, jsn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment