繁体   English   中英

有没有其他方法可以使用多个 arguments 写入文件?

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

有没有其他方法可以使用多个 arguments 写入文件?

在此处输入图像描述

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

f.write("=" * 40 + str("System Information") + str("=" * 40)) 即使这符合我的要求

使用printfile参数并给它一个有效的文件句柄。 这样您就可以使用任意数量的 arguments。

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

请注意,如果您不想让字符串以空格分隔,则可以根据需要调整 print function 的sep参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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