Skip to main content
 首页 » 编程设计

python之尝试在 zapier 上运行 python 代码时出错

2025年04月02日17wuhuacong

我有以下地址:

556_StreetName_Ave_CityName_11111 

我想用代码剪掉最后一部分,_Ave_CityName_11111

所以基本上我想删除最后 3 个下划线的所有内容。

这是我的代码:

output = "_".join(input['street_name'].split("_")[:-3]) 

但是我得到一个错误:

Bargle. We hit an error creating a run python. :-( Error:  
'unicode' object has no attribute 'copy' 

这是我在 Zapier 中的设置:

screenshot

请您参考如下方法:

output = {'street_name': "_".join(input['street_name'].split("_")[:-3])}

这实际上是允许它在有人需要帮助时工作的代码。

感谢 IRC phython channel nedbat 的帮助!!