Python 2.7 我想使用ansible将目录中的文件名打印为列表

Python 2.7 我想使用ansible将目录中的文件名打印为列表,python-2.7,ansible,Python 2.7,Ansible,我得到的结果是: 但我想把它当作 --- - hosts: localhost user: root tasks: - command: "ls /root/Tmp/Deployment/script_files/Hotfix" register: dir_out - debug: msg="The hotfix ids are: {{dir_out.stdout_lines}}" 我该怎么做?我需要将:{{dir\u out.stdout

我得到的结果是:

但我想把它当作

---
  - hosts: localhost
    user: root

    tasks:
    - command: "ls /root/Tmp/Deployment/script_files/Hotfix"
      register: dir_out

    - debug: msg="The hotfix ids are: {{dir_out.stdout_lines}}"

我该怎么做?

我需要将:
{{dir\u out.stdout\u lines}
更改为
{dir\u out.stdout\u lines}join(',')}

你的剧本、结果和预期的字符串都是虚构的。他们在不同的地方有
,剧本不会因为这个角色而运行;结果包括剧本中不存在的
|列表
;您期望的字符串包含双引号(如果是必需的,则没有解释)。当你在StackExchange上提问时,你应该包括可验证的代码。剧本是可验证的。除此之外,我怎样才能产生一个输出呢?我实际上也有一个解决方案。我需要将:{dir_out.stdout_lines}更改为{{dir_out.stdout_lines}并以所需的方式输出打印。您包含的输出与剧本几乎没有关系,我已经指出了这一点。
The hotfix ids are :["1001","1002"]