到目前为止,这是我的代码:
In [87]: str_ = 'AZ|C|DTD'
# Gets the partitions spitted on first `|`
# generates 3 element tuple: `('AZ', '|', 'C|DTD')`
In [88]: parts = str_.partition('|')
# Concatenate after joining first two elements with
# empty string, `BA|` and last element
In [89]: ''.join(parts[:2]) + 'BA|' + parts[2]
Out[89]: 'AZ|BA|C|DTD'

示例:["爆炸"," incendiary_device"];
我想在turnArray()函数中执行此操作。我怎么能这样做?