小编twe*_*ner的帖子

vba Dictionary - 从Items返回KEY()

我有一本字典,每个VALUE字典都是另一本字典.在我的代码中,我循环使用顶级字典.Items()(i).顺便说一句,它需要保持这种方式.

Dim dic As New Scripting.Dictionary
Dim myValue As New Scripting.Dictionary

For i = 0 to dic.count-1
  ' 
  ' the VALUE of the KEY/VALUE pair is...
  set myValue = dic.Items()(i) 
  '
  ' how do I retrieve the KEY???
  '
Next i
Run Code Online (Sandbox Code Playgroud)

我的问题:

如何在此循环结构中检索顶级字典的KEY?这可能是非常明显的,我只是在这里画一个空白.

excel vba dictionary excel-vba

3
推荐指数
2
解决办法
1万
查看次数

python中的unicodecsv阅读器出现问题

我在使用unicodecsv阅读器时遇到问题。我一直在寻找有关如何使用该模块的不同示例,但是每个人都在不断引用unicodecsv网站(或一些类似的变体)中的确切示例。

import unicodecsv as csv
from io import BytesIO
f = BytesIO()
w = csv.writer(f, encoding='utf-8')
_ = w.writerow((u'é', u'ñ'))
_ = f.seek(0)
r = csv.reader(f, encoding='utf-8')
next(r) == [u'é', u'ñ']
>>> True
Run Code Online (Sandbox Code Playgroud)

对我来说,这个例子对我们的理解做出了太多假设。看起来好像没有传递csv文件。我完全错过了情节。

我想做的是:

  1. 读取csv文件的第一行,它们是标题
  2. 阅读剩余的几行并将其放入字典中

我的断码:

import unicodecsv
#
i = 0
myCSV = "$_input.csv"
dic = {}
#
f = open(myCSV, "rb")
reader = unicodecsv.reader(f, delimiter=',')
strHeader = reader.next()
#
# read the first line of csv
# use custom function to parse the header
myHeader = …
Run Code Online (Sandbox Code Playgroud)

python csv unicode

0
推荐指数
1
解决办法
6136
查看次数

标签 统计

csv ×1

dictionary ×1

excel ×1

excel-vba ×1

python ×1

unicode ×1

vba ×1