[英]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?有没有其他方法可以使用多个 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 f.write("=" * 40 + str("System Information") + str("=" * 40)) 即使这符合我的要求
Use the file
parameter of print
and give it a valid file handle.使用
print
的file
参数并给它一个有效的文件句柄。 This way you can use an arbitraty amount of arguments.这样您就可以使用任意数量的 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.请注意,如果您不想让字符串以空格分隔,则可以根据需要调整 print function 的
sep
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.