小编neo*_*neo的帖子

在python中压缩文件

我的程序运行顺利,但我希望我的ftp文件在我的本地驱动器中压缩

我的问题:调用main()函数后只压缩了1个文件

这是我的代码:

主要

import os
import upload
import download
import zipfile
import ConfigParser
import ftputil

def main():

    #create a folder Temp on d drive for later use
    path = r'D:\Temp'
    os.mkdir(path)

    #parse all the  values at config.ini file
    config = ConfigParser.ConfigParser()
    config.readfp(open('config.ini'))
    server = config.get('main', 'Server')
    username = config.get('main', 'Username')
    password = config.get('main', 'Password')
    uploads = config.get('main', 'Upload folder')
    downloads = config.get('main', 'Download folder')

    #connect to ftp
    ftp = ftputil.FTPHost(server, username, password)

    dirlist = ftp.listdir(downloads)

    for list in dirlist: …
Run Code Online (Sandbox Code Playgroud)

python zip zipfile ftputil

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

在组合框中实现IDataErrorInfo

我在验证ComboBox使用时遇到问题IDataErrorInfo.

我设置了1个文本框和1个组合框,在运行程序时,第一个焦点在文本框上,当我按Tab键聚焦在我得到的组合框中时:

InvalidOperationException:在'System.Windows.Controls.ToolTip'的名称范围内找不到'validationTooltip'名称.

为了帮助你在这里帮助我,我的XAML的一部分:

<Window.DataContext>
    <ViewModels:MainWindowViewModel/>
</Window.DataContext>

<!-- Batch ID-->
<Label Content="Batch ID"
       Height="28" 
       Margin="64,52,191,0" VerticalAlignment="Top" />
<TextBox Name="txtBatchId" 
    Text="{Binding BatchId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
    Margin="124,52,65,0" TabIndex="1" Height="26" VerticalAlignment="Top" />

<!-- Product -->
<Label Content="Product" 
    Height="28" Margin="54,81,191,0" VerticalAlignment="Top" />
<ComboBox Name="cmbProduct" 
    ItemsSource="{Binding Products}" 
    DisplayMemberPath="ProductName" 
    SelectedValuePath="ProductId"
    SelectedValue="{Binding SelecteProductId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,  ValidatesOnDataErrors=True}"  
    Height="23" Margin="124,81,65,0" VerticalAlignment="Top" TabIndex="2" />
Run Code Online (Sandbox Code Playgroud)

这ProductModel.cs是在数据绑定组合框中使用的:

public class ProductModel
{
    public int ProductId {get;set;}
    public int ProductName {get;set;}

    public ProductModel(int prodId, string prodName)
    {
        ProductId …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm

7
推荐指数
1
解决办法
2004
查看次数

使用ElementTree在Python中处理XML

我有一个ElementTree.iter()的问题.

所以我在这个链接中尝试了这个例子:http://eli.thegreenplace.net/2012/03/15/processing-xml-in-python-with-elementtree/

所以这就是我尝试过的:

import elementtree.ElementTree as ET
tree = ET.parse('XML_file.xml')
root = tree.getroot()
for elem in tree.iter():
    print elem.tag, elem.attrib
Run Code Online (Sandbox Code Playgroud)

我得到这个错误AttributeError:ElementTree实例没有属性'iter'

附加信息:我的Python版本是2.4我单独安装了elementtree.我提供的链接中的其他示例是在我的Python中安装.只有ElementTree.iter()不起作用.在此先感谢您的所有帮助.干杯!

python xml parsing elementtree

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

清除listview的所有项目 - c#

如何在C#中清除ListView?

以下是我填充ListView的方法:

int listViewCounter = 0;
for (int i = 0; i < dtXLS.Rows.Count; i++)
{
    listViewCounter++;

    ListViewItem item = new ListViewItem();
    item.Text = "First item" + listViewCounter;
    item.SubItems.Add("sadad" + listViewCounter);
    item.SubItems.Add("sadad" + listViewCounter);
    item.SubItems.Add("sadad" + listViewCounter);
    item.SubItems.Add("sadad" + listViewCounter);
    LV.Items.Add(item);

    LV.Items[listViewCounter - 1].SubItems[0].Text = listViewCounter.ToString();
    LV.Items[listViewCounter - 1].SubItems[1].Text = "sample1";
    LV.Items[listViewCounter - 1].SubItems[2].Text = "sample2";
    LV.Items[listViewCounter - 1].SubItems[3].Text = "sample3";
    LV.Items[listViewCounter - 1].SubItems[4].Text = "sample4";
}
Run Code Online (Sandbox Code Playgroud)

结果将是:

1st Column    2nd Column    3rd Column    4th Column    5th Column
1             sample1 …
Run Code Online (Sandbox Code Playgroud)

.net c# listview

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

标签 统计

c# ×2

python ×2

.net ×1

elementtree ×1

ftputil ×1

listview ×1

mvvm ×1

parsing ×1

wpf ×1

xml ×1

zip ×1

zipfile ×1