[英]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)) 即使这符合我的要求
使用print
的file
参数并给它一个有效的文件句柄。 这样您就可以使用任意数量的 arguments。
print(..., ..., ..., file=f)
请注意,如果您不想让字符串以空格分隔,则可以根据需要调整 print function 的sep
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.