悬赏园豆:80
[已关闭问题]
我在看IronPython的时候,看到一种数据存储类型,不知道是什么东东。。到处找资料也找不到。<br>源码来自微软的IronPython网站,eg:<br><div class="cnblogs_code"><img src="/Images/OutliningIndicators/ContractedBlock.gif" id="Code_Closed_Image_080646" onclick="this.style.display='none'; Code_Closed_Text_080646.style.display='none'; Code_Open_Image_080646.style.display='inline'; Code_Open_Text_080646.style.display='inline';" width="11" align="top" height="16"><img src="/Images/OutliningIndicators/ExpandedBlockStart.gif" id="Code_Open_Image_080646" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_080646.style.display='none'; Code_Closed_Image_080646.style.display='inline'; Code_Closed_Text_080646.style.display='inline';" width="11" align="top" height="16"><span id="Code_Closed_Text_080646" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">Code</span><span id="Code_Open_Text_080646" style="display: none;"><br><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">1</span><img src="/Images/OutliningIndicators/None.gif" align="top"><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);">:<br></span><span style="color: rgb(0, 128, 128);">2</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> reader </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> cmd.ExecuteReader()<br></span><span style="color: rgb(0, 128, 128);">3</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> result </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> []<br></span><span style="color: rgb(0, 128, 128);">4</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> reader.Read():<br></span><span style="color: rgb(0, 128, 128);">5</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> fields </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> dict([(reader.GetName(i), reader.GetValue(i)) </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> range(reader.FieldCount)])<br></span><span style="color: rgb(0, 128, 128);">6</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> result.append(DB.__DataRow(fields))<br></span><span style="color: rgb(0, 128, 128);">7</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> result<br></span><span style="color: rgb(0, 128, 128);">8</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);">:<br></span><span style="color: rgb(0, 128, 128);">9</span><span style="color: rgb(0, 0, 0);"><img src="/Images/OutliningIndicators/None.gif" align="top"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> reader: reader.Close()</span></span></div> 代码中的这句:<br><div class="cnblogs_code"><span style="color: rgb(0, 0, 0);">dict([(reader.GetName(i), reader.GetValue(i)) </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> range(reader.FieldCount)])<br>dict感觉是一个函数,又不是很像,完整的代码返回的数据是data([list]),我不知道这个是什么类型的数据,更不知道怎么转换处理,请高手找指教。。<br></span></div>
聽雨
|
初学一级
|
园豆:
30
提问于:2008-07-31 08:08