2

How can we transform a list of string or a list of object to a ListViewItemCollection in one line with linq, where object is for example a person with Name property that will be displayed to the ListViewItem.

Here is my current code :

foreach (string word in sf.lstWords)
{
  lvWords.Items.Add(new ListViewItem(word));
}

Pipe email from procmail to python script that parses body and saves as text file

I'm building a data loggerr and I've spent a lot of time trying to get this right, every forum takes me in a different direction and I think a weekend of googling warrants submitting a question here.

I'm running Ubuntu 12.10, I use fetchmail to get my mail, it sends it to procmail, and I have procmail piping it to a python script that is supposed to parse the body, and save it to a text file. The problem is I can't figure out how to write a python script that will do this, every example I find online is a bit over my head and I was hoping someone could take a little time to help me understand how this could be accomplished.

4

1 に答える 1

11

使い方ListView.ListViewItemCollection.AddRangeとLinqメソッドSelect

lvWords.Items.AddRange(sf.lstWords.Select(t => new ListViewItem(t)).ToArray());

ToArray()AddRange の署名が無効なので使用しますAddRange(ListViewItem[])

于 2013-02-03T19:33:42.787 に答える