如何避免类型转换警告? [英] How to avoid type conversion warnings?

查看:23
本文介绍了如何避免类型转换警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用带有循环的 dconf 模块

When I use the dconf module with a loop

- name: dconf | modify settings
  dconf:
    key: "{{ item.key }}"
    value: "{{ item.value }}"
    state: present
  loop:
    - key: "/org/gnome/libgnomekbd/keyboard/layouts"
      value: "['us', 'se']"
    - key: "/org/cinnamon/panels-height"
      value: "['1:40']"
  tags: "dconf"

我收到这样的警告:

[警告]:字符串字段中的值 ['us', 'se'](类型列表)被转换为['us', 'se']"(类型细绳).如果这看起来不像您期望的那样,请引用整个值以确保它不会改变.

[WARNING]: The value ['us', 'se'] (type list) in a string field was converted to "['us', 'se']" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

[警告]:字符串字段中的值 ['1:40'](类型列表)已转换为['1:40']"(类型字符串).如果这看起来不像您期望的那样,请引用整个值以确保它不会更改.

[WARNING]: The value ['1:40'] (type list) in a string field was converted to "['1:40']" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

我尝试了所有可能的方法来引用该值,但没有结果

I tried all possible ways to quote the value but without result

推荐答案

你试过了吗

value: "{{ item.value |string }}"

这篇关于如何避免类型转换警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆