简体   繁体   中英

Is there any other way to write into a file using more than one arguments?

Is there any other way to write into a file using more than one arguments?

enter image description here

type error: write() takes exactly one argument (3 given)

f.write("=" * 40 + str("System Information") + str("=" * 40)) even this is working for my requirement

Use the file parameter of print and give it a valid file handle. This way you can use an arbitraty amount of arguments.

print(..., ..., ..., file=f)

Note that you can adjust the sep parameter of the print function as required if you don't want to have your strings whitespace-separated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM