如果被字符包围,则不会替换嵌入式表达

时间:2018-06-11 17:16:24

标签: character karate

在以下简化和非常基本的场景中,当附加,前置或由字符包围时,嵌入式表达式不会被替换:

df_one_ = df_one.merge(df_other_one, on='Sr.No.')
print(df_one_)

     Sr.No. Apartment Type  Carpet Area (in Sqmts)  Number of Apartment  \
0       1          Shops                   70.63                    6   

   Number of Booked Apartment     Project Name     Name  \
0                           0  SRUSHTI COMPLEX  A and B   

  Proposed Date of Completion Number of Basement's Number of Plinth  \
0                         NaN                    0                1   

  Number of Podium's Number of Slab of Super Structure Number of Stilts  \
0                  0                                 5                1   

  Number of Open Parking Number of Closed Parking  
0                     48                        1 


df_two_ = df_two.merge(df_other_two, on='Sr.No.')
print(df_two_)


     Sr.No. Apartment Type  Carpet Area (in Sqmts)  Number of Apartment  \
0       2           1BHK                 1409.68                   43   

   Number of Booked Apartment     Project Name     Name  \
0                           4  SRUSHTI COMPLEX  C and D   

  Proposed Date of Completion Number of Basement's Number of Plinth  \
0                         NaN                    0                1   

  Number of Podium's Number of Slab of Super Structure Number of Stilts  \
0                  0                                 5                1   

  Number of Open Parking Number of Closed Parking  
0                     51                        1 

执行方案返回:

* def jobId = '0001'
* def out = 
        """
        {
            "jobId": "#(jobId)",
            "outputMetadata": {
                "fileName_OK": "#(jobId)",
                "fileName_Fail_1": "some_text_#(jobId)",
                "fileName_Fail_2": "#(jobId)-and-some-more-text",
                "fileName_Fail_3": "prepend #(jobId) and append"
            }
        }
        """
* print out

是功能,限制还是错误?或者,我错过了什么?

1 个答案:

答案 0 :(得分:0)

这是设计的!你可以这样做:

"fileName_Fail_2": "#(jobId + '-and-some-more-text')"

任何有效的JS表达式都可以填充到嵌入式表达式中,因此这不是限制。这仅适用于JSON字符串值,或者当整个RHS是引号内的字符串并保持解析简单时。希望有所帮助!