-3

I am trying to fetch the free disk space details of each drive using Python Scripts and storing the values in a variable 'p'.

p=(disk_usage('C:/'))
    f=open('C:\\Python27\\solr.log','a')
    f.write("Solr "+p)

I would like to place the results from variable 'p' into a log file. If I print the variable 'p', I am able to get the results successfully. But when I try to open a log file and write into it, it is throwing the below error.

"Traceback (most recent call last):
  File "C:\Python27\sample.py", line 51, in <module>
    f.write("Result: "+p)
TypeError: must be str, not UsageTuple"

Could anyone please help me on this.

  • 3
    I'm voting to close this question as off-topic because SO is not a code writing service. Please show your efforts – EdChum Nov 15 '17 at 11:12
  • Please tell about your efforts and the problems you are facing in a more detailed manner – saud Nov 15 '17 at 11:13

1 Answers1

0

I got the answer. Just changed the 'p' variable to string and then I tried to write into file. I am able to get the results in my log file.