如何将值对添加到excel,而不包括python字典中的括号?

如何将值对添加到excel,而不包括python字典中的括号?,python,Python,我想在python字典中附加键值对,但不包括括号。。。我真的不知道该怎么做 我试过看类似的问题,但对我不起作用 #this creates a new workbook call difference file = xlrd.open_workbook('/Users/im/Documents/Exception_Cases/Orders.xls') wb = xl_copy(file) Sheet1 = wb.add_sheet('differences') #this creates he

我想在python字典中附加键值对,但不包括括号。。。我真的不知道该怎么做

我试过看类似的问题,但对我不起作用

#this creates a new workbook call difference
file = xlrd.open_workbook('/Users/im/Documents/Exception_Cases/Orders.xls')
wb = xl_copy(file)
Sheet1 = wb.add_sheet('differences')

#this creates header for two columns
Sheet1.write(0,0,"S_Numbers")
Sheet1.write(0,1," Values")

#this would store all the of Key, value pair of my dictionary into their respective SO_Numbers, Booking Values column

print(len(diff_so_keyval))
rowplacement = 1
while rowplacement < len(diff_so_keyval):
    for k, v in diff_so_keyval.items():
        Sheet1.write(rowplacement,0,k)
        Sheet1.write(rowplacement,1,str(v))
        rowplacement = rowplacement + 1

#This is what I have in my diff_so_keyval dictionary 

diff_so_keyval = {104370541:[31203.7]
106813775:[187500.0]
106842625:[60349.8]
106843037:[492410.5]
106918995:[7501.25]
106919025:[427090.0]
106925184:[30676.4]
106941476:[203.58]
106941482:[203.58]
106941514:[407.16]
106962317:[61396.36]}

#this is the output
S_numbers       Values
104370541   [31203.7]
106813775   [187500.0]
106842625   [60349.8]

I want the values without the brackets
#这将创建一个新的工作簿调用差异
file=xlrd.open_工作簿(“/Users/im/Documents/Exception_Cases/Orders.xls”)
wb=xl_副本(文件)
Sheet1=wb.添加表格(“差异”)
#这将为两列创建标题
表1.书写(0,0,“S_编号”)
表1.书写(0,1,“值”)
#这将把我字典中的所有键、值对存储到它们各自的SO_编号、预订值列中
打印(len(diff_so_keyval))
行位置=1
当行位置
在我看来,字典中的“值”实际上是单元素列表

如果您只是从列表中提取第0个元素,那么这对于“删除括号”应该有用:

        Sheet1.write(rowplacement, 1, v[0])

在我看来,字典中的“值”实际上是单元素列表

如果您只是从列表中提取第0个元素,那么这对于“删除括号”应该有用:

        Sheet1.write(rowplacement, 1, v[0])

包含足够的代码以允许其他人重现问题。有关这方面的帮助,请阅读如何创建一个最小、完整且可验证的示例。包含足够的代码以允许其他人重现问题。有关这方面的帮助,请阅读如何创建一个最小、完整且可验证的示例。如果我有多个元素列表会发生什么情况,我应该怎么做?这取决于您希望如何处理每个列表元素。例如,您可以在
for
循环中迭代
v
,并为每个唯一值打印一行,所有值共享相同的
k
。如果我有多个元素列表,该怎么办?这取决于您希望对每个列表元素做什么。例如,您可以在
for
循环中迭代
v
,并为每个唯一值打印一行,所有这些值共享相同的
k