擅长:python、mysql、java
<p>您可以将字典导入数据帧。然后可以将其导出为csv,而不使用列名,以实现所需的功能</p>
<p>下面的代码片段可以实现此目的:</p>
<pre><code>import pandas as pd
df = pd.DataFrame.from_dict({(i,j): Inventory[i][j]
for i in Inventory.keys()
for j in Inventory[i].keys()},
orient='index')
df.to_csv('test.csv', header = False)
</code></pre>
<p>对于问题中显示的名为<code>Inventory</code>的词典,您的<code>test.csv</code>就是这样的:</p>
<pre><code>devicename,Interface1,value,value
devicename,Interface2,value,value
</code></pre>