如果存在一个简单的.txt-04目录,请参阅“我在使用一个简单的.txt-04目录下的程序。我有两个问题。在
A)我想在正则表达式中使用变量datestr。不知道该怎么做。在
B)其次,我的打印(文件名)在airflow UI中显示在哪里?我查了查看日志,但什么也没显示出来。在
def checksFile():
d = datetime.today()-timedelta(days=1)
datestr = '{:%Y-%m-%d}'.format(d)
for filename in os.listdir('/mnt/volume/home/aabraham/'):
match = re.search('(test)-(2018-06-04)-(\d+)(\.txt)', filename)
print(filename)
if not match:
raise AirflowException("File not Found")
不能以控制台中相同的方式使用
print
。在要查看
Log
页面中的日志条目,请使用logging.info
。也许你需要import logging
。在要回答regex问题,只需将字符串添加到一起:
只有当
datestr
不包含任何regex文本时,这才有效。在相关问题 更多 >
编程相关推荐