擅长:python、mysql、java
<p>最好的方法是从上下文中获取执行日期,该日期已经传递给execute(self,context)</p>
<p>例如,我在这里设置执行日期的字符串表示形式:</p>
<pre><code>self.execution_date_str = context["execution_date"].strftime("%Y-%m-%d")
</code></pre>
<p><a href="https://github.com/apache/airflow/blob/master/airflow/operators/latest_only_operator.py#L53-L54" rel="nofollow noreferrer">Example in LatestOnlyOperator</a></p>