【问题标题】:Zapier Python zap that I want to check if a field endswith .mov我想检查一个字段是否以 .mov 结尾的 Zapier Python zap
【发布时间】:2019-05-22 23:09:57
【问题描述】:

我正在尝试使用 python 代码块测试 Zapier 字段,以查看它是否以 .mov 结尾。如果是这样,我想删除 .mov。如果不是,则按原样返回该字段。我的代码可以工作,但我添加了一个 .lower() 以使其工作,但不明白为什么它会这样。

我尝试了多种变体,但似乎唯一可行的是在变量中添加字符串格式 .lower()。

formatted_str = input_data['text']
if formatted_str.endswith('.mov'):
    formatted_str = formatted_str[:-4]
return {'formatted_str':formatted_str.lower()}

我想返回结果,而不必将其更改为全部小写。我知道这是可能的,但我没有任何运气。非常感谢!

【问题讨论】:

  • 如果不包含.lower 会发生什么?有错误吗?
  • 感谢您的回复。抱歉,需要编辑答案。它是:formatted_str = input_data['text'] if formatted_str.endswith('.mov'): formatted_str = formatted_str[:-4] return {'text':formatted_str}

标签: python zapier


【解决方案1】:

在 Zapier 人的帮助下,我发现了我的问题。谢谢!

formatted_str = input_data['text']
if formatted_str.endswith('.mov'):
    formatted_str = formatted_str[:-4]
return {'text':formatted_str}

【讨论】:

    猜你喜欢
    • 2012-09-06
    • 1970-01-01
    • 2019-12-17
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 2014-06-12
    • 2011-04-29
    相关资源
    最近更新 更多