小编Let*_*tt1的帖子

在c#7中创建System.ValueTuple数组

在我的代码中,我有:

private static readonly ValueTuple<string, string>[] test = {("foo", "bar"), ("baz", "foz")};
Run Code Online (Sandbox Code Playgroud)

但是当我编译我的代码时,我得到:

TypoGenerator.cs(52,76):  error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,84):  error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(52,94):  error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,103):  error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(117,42):  error CS1525: Unexpected symbol `('
TypoGenerator.cs(117,58):  error CS1525: Unexpected symbol `['
Run Code Online (Sandbox Code Playgroud)

创建和初始化ValueTuples数组的正确方法是什么?

c#

11
推荐指数
2
解决办法
4727
查看次数

Celery:使用多个参数链接任务

celery文档告诉我,如果多个任务链接在一起,第一个任务的结果将是下一个任务的第一个参数.我的问题是,当我有一个返回多个结果的任务时,我无法让它工作.

例:

@task()
def get_comments(url):
    #get the comments and the submission and return them as 2 objects
    return comments, submission

@task
def render_template(threadComments, submission):
    #render the objects into a html file
    #does not return anything
Run Code Online (Sandbox Code Playgroud)

现在,如果我在链接中调用它们(get_comments(url)| render_template()).apply_asnc()python将抛出一个TypeError: render_template() takes exactly 2 arguments (0 given).

我可以看到结果没有打开并应用于参数.如果我只调用get_comments,我可以这样做:

result = get_comments(url)
arg1, arg2 = result
Run Code Online (Sandbox Code Playgroud)

并得到两个结果.

python celery

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

标签 统计

c# ×1

celery ×1

python ×1