You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Power Automate中将不同格式数值字符串统一转换为整数

Power Automate 多格式数字字符串转整数实现方案

核心处理逻辑为先清理字符串中的非标准符号,再统一数值格式,最后按需取整转换,具体操作步骤如下:

  • 第一步:清理千位空格
    使用replace()函数删除字符串中的千位分隔空格,表达式:
    replace(variables('待转换原始字符串变量'), ' ', '')
  • 第二步:统一小数分隔符
    将逗号格式的小数分隔符替换为Power Automate可识别的小数点,表达式:
    replace(outputs('清理空格后的结果'), ',', '.')
  • 第三步:转换为浮点数值
    调用float()函数将处理后的标准格式字符串转为数值类型,表达式:
    float(outputs('替换分隔符后的结果'))
  • 第四步:按规则转换为整数
    根据业务需求选择对应取整逻辑:
    1. 截断取整(直接丢弃小数部分):int(outputs('浮点数值结果'))
    2. 四舍五入取整:int(round(outputs('浮点数值结果'), 0))
    3. 向上取整:int(ceiling(outputs('浮点数值结果')))
    4. 向下取整:int(floor(outputs('浮点数值结果')))
  • 单表达式简化写法(无需中间变量,以截断取整为例):
    int(replace(replace(variables('待转换原始字符串变量'), ' ', ''), ',', '.'))

测试样例验证(截断取整规则下):
输入480 000 → 输出480000
输入0 → 输出0
输入-0,03 → 输出0
输入452 000,23 → 输出452000

内容的提问来源于stack exchange,提问作者Kair0

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 19:18:03