How to write multiple values to a text file in Python

2 Answers

0 votes
with open("d:\\data.txt", "w") as file:
    file.write("%s %s\n" % (int(25), "abc"))


'''
run:

25 abc

'''

 



answered Oct 21, 2017 by avibootz
0 votes
with open("d:\\data.txt", "w") as file:
    file.write("%s %s %s\n" % (float(12.87), "c", "python"))


'''
run:

12.87 c python

'''

 



answered Oct 21, 2017 by avibootz

Related questions

1 answer 220 views
2 answers 267 views
267 views asked Jun 22, 2020 by avibootz
1 answer 198 views
2 answers 288 views
2 answers 367 views
...