Is there any simpler way for writing a string to a file than this:
f = open("test.txt", "w+")
f.write("test")
f.close()
I wish the return value of write was not None so that I could do this:
open("test.txt", "w+").write("test").close()
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you use
with open, you don’t need to dof_out.close(); this is done for you automatically.