擅长:python、mysql、java
<p>模式<code>a</code>意味着追加(yust意味着在末尾继续写入),所以so永远无法覆盖任何内容。
而是使用模式<code>w</code>,它代表允许覆盖的写操作。
有关更多信息,请查看文档:<a href="https://pandas.pydata.org/docs/reference/api/pandas.ExcelWriter.html" rel="nofollow noreferrer">https://pandas.pydata.org/docs/reference/api/pandas.ExcelWriter.html</a></p>
<pre><code>with pd.ExcelWriter(self.filename, mode='w', if_sheet_exists='replace', engine="openpyxl") as writer:
self.df_holders.to_excel(writer, sheet_name='test')
</code></pre>
<p>希望这有帮助D</p>