python - How to Print this statment in to a txt file -


i trying write txt file getting typeerror. how go this? here code below:

yesterdays_added = f1_set - f2_set yesterdays_removed = f2_set -f1_set open('me{}{}{}.txt'.format(dt.year, '%02d' % dt.month, '%02d' % dt.day), 'w') out:     line in todays:         if line in yesterdays_added:             out.write( 'removed', line.strip())         elif line in yesterdays_removed:             out.write ('added', line.strip())       line in yesterdays:        if line in yesterdays_added:             out.write ('removed', line.strip())         elif line in yesterdays_removed:             out.write ('added', line.strip()) 

this error getting:

 out.write ('added', line.strip()) typeerror: function takes 1 argument (2 given) 

you need concatenate together.

out.write("added "+line.strip()) # or out.write("added {}".format(line.strip())) 

for example,

>>> "added "+"abc\n".strip() 'added abc' 

from the python docs

f.write(string) writes contents of string file, returning none.

whenever in doubt, use help().

write(...)     write(str) -> none.  write string str file. 

this says write() takes in 1 argument. (whereas provide 2, hence error)


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -