How to use 'python save list to txt' in Python

Every line of 'python save list to txt' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
60def write_txt(str):
61 with open('answers_all.txt', 'a') as f:
62 f.write(str)
63def write_txt(path, fname, contents, flag=False):
64 make_directory(path)
65 full_path = os.path.join(path,fname)
66 log = open(full_path, 'a')
67 log.write(contents + '\n')
68 log.close()
69 if (flag):
70 print '-> [%s] has been written in %s.' % (contents, fname)

Related snippets