I have a list in following format and need to replace commas with backlash but getting error when trying to use replace function.
"sub_keys": [ ",,ps1,printer1", ",,ps1,printer2", ",,ps2,printer1"] expected result: new_list:[ "\\\\ps1\\printer1", "\\\\ps1\\printer2" "\\\\ps2\\printer1"]
i tried the following code:
- name: Convert list set_fact: new_list: '{{ new_list + [item.replace (",","\\")] }}' with_items: "{{ sub_keys }}"
Have you tried:
- name: Convert list
set_facts:
new_list:
- "\\\\ps1\\printer1"
- "\\\\ps1\\printer2"
- "\\\\ps2\\printer1"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.