簡體   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