Guest User

Untitled

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import os
  2.  
  3. directory = os.path.normpath("file path to folder")
  4. for subdir, dirs, files in os.walk(directory):
  5. for file in files:
  6. if file.endswith(".txt"):
  7. f=open(os.path.join(subdir, file),'r')
  8. a = f.read()
  9. print a
  10. r = requests.post(url1,data=a).content
  11. file = 'file path to write api response'
  12. f = open(file, 'a+')
  13. f.write(r)
  14. f.close()
Add Comment
Please, Sign In to add comment