在我的代码中,我有:
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数组的正确方法是什么?
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)
并得到两个结果.