小编Cor*_*ane的帖子

有人可以解释在此Python程序中*的用法吗?

if __name__ == '__main__':
    n = int(input())
    student_marks = {}
    for _ in range(n):
        name, *line = input().split()
        scores = list(map(float, line))
        student_marks[name] = scores
    query_name = input()
Run Code Online (Sandbox Code Playgroud)

有人可以*在上面的Python代码段中解释的用法吗?

python dictionary python-3.x

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

“哪里”和“选择”在 LINQ 中是如何工作的?

我有以下代码片段。我对后面提到的代码片段几乎没有疑问。

var salaries = customerList
                    .Where(c => c.Age > 30)
                    .Select(c => c.Salary) // salary is of type long
                    .ToList();
Run Code Online (Sandbox Code Playgroud)
  • 在上面的代码片段中,“Where”如何访问 customerList 以及它如何定义“c”的类型?
  • 在应用 Select 所作用的过滤器后,“Where”是否会返回一个临时的客户列表?
  • “Select”究竟是如何知道它只需要返回“Salary”的?
  • 变量“salaries”的类型如何设置为 List<long>?

c# linq

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

Python,用“with”语句包装函数的装饰器

在 Python 3.7+ 中,有没有办法创建一个采用类似方法的装饰器:

@some_dec_fun
def fun():
    ...
Run Code Online (Sandbox Code Playgroud)

并转换并执行类似的东西

def fun():
    with some_dec_fun():
        ...
Run Code Online (Sandbox Code Playgroud)

python python-3.x

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

如何使用按钮将多个参数传递给 WPF 命令?

目前我的代码如下所示:

<Button Command="{Binding DrinkCommand}" CommandParameter="Capuccino" Style="{StaticResource DrinkButton}">
    <TextBlock>Capuccino</TextBlock>
</Button>
<Button Command="{Binding DrinkWithSugarCommand}" CommandParameter="Capuccino" Style="{StaticResource DrinkButton}">
    <TextBlock>Capuccino + sugar</TextBlock>
</Button>
Run Code Online (Sandbox Code Playgroud)

你可以看到我RelayCommand对加糖和不加糖的卡布奇诺有不同的选择。

我想添加添加额外牛奶的选项。但是我会得到:

DrinkCommand,

DrinkWithSugarCommand,

DrinkWithMilkCommand,

DrinkWithSugarAndMilkCommand

有没有办法让他们知道DrinkCommand我想要加糖和/或牛奶的饮料(卡布奇诺)?

c# wpf xaml

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

将类型 Task&lt;IEnumerable&gt; 转换为类型 IEnumerable

我有以下类型的表达式Task<IEnumerable<PendingApprovalUserChangeRequest>>,我需要将其转换为IEnumerable<PendingApprovalUserChangeRequest>. 我怎么做 ?

Task<IEnumerable<PendingApprovalUserChangeRequest>> pendingChangeRequest = service.GetPendingChangeRequest();
Run Code Online (Sandbox Code Playgroud)

c# task async-await

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

如何解决“索引超出数组范围”。同时添加到列表中

我正在尝试将项目添加到列表中,但是我面临以下问题

指数数组的边界之外。

添加项目时出错。我正在使用BOT框架。

我尝试过更改List为,ConcurrentBag但仍不能解决问题。

public static async Task refreshCatagoryLuis(ITurnContext turnContext)
{
    var luisCategoryIntents = await getCatagoryLuisIntentsList("*****-********-******-****");
    ConcurrentBag<string> catagoryList = new ConcurrentBag<string>();
    for (int i = 0; i <= luisCategoryIntents.Length; i++)
    {
        catagoryList.Add(luisCategoryIntents[i].Name);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# .net-core

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

标签 统计

c# ×4

python ×2

python-3.x ×2

.net-core ×1

async-await ×1

dictionary ×1

linq ×1

task ×1

wpf ×1

xaml ×1