---
- hosts: test
tasks:
- name: print phone details
debug: msg="user {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
with_dict: users
vars:
users:
alice: "Alice"
telephone: 123
Run Code Online (Sandbox Code Playgroud)
当我运行这个剧本时,我收到此错误:
One or more undefined variables: 'dict object' has no attribute 'name'
Run Code Online (Sandbox Code Playgroud)
这个实际上工作得很好:
debug: msg="user {{ item.key }} is {{ item.value }}"
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我正在做ionic2项目。我刚刚开始使用,moment.js但是有一个奇怪的问题。我已经通过npm安装了:npm install moment -S。
然后在代码中使用了它:
import moment from 'moment'
...
let x = moment()
debugger
Run Code Online (Sandbox Code Playgroud)
在控制台上,我得到一个有趣的问题:
> x
< Moment {_isAMomentObject: true, _isUTC: false, _pf: {…}, _locale: Locale, _d: Wed Jun 27 2018 12:06:23, …}
> y = moment()
< VM770:1 Uncaught ReferenceError: moment is not defined
at eval (eval at Phase (phase.ts:13), <anonymous>:1:1)
at new Phase (phase.ts:13)
at new Stage (stage.ts:10)
at new HomePage (home.ts:39)
at createClass (core.es5.js:10795)
at createDirectiveInstance (core.es5.js:10621)
at createViewNodes …Run Code Online (Sandbox Code Playgroud) 如果我有这样的6长度列表:
l = ["AA","BB","CC","DD"]
我可以打印出来:
print "%-2s %-2s %-2s %-2s" % tuple(l)
输出将是:
AA BB CC DD
但如果列表l可以是任何长度怎么办?有没有办法以相同的格式打印具有未知数量元素的列表?
我只想抓住以下其中一项:
01 , 02 , ... , 09 , 10 , 11 , 12
Run Code Online (Sandbox Code Playgroud)
以下正则表达式是完整还是我错过了什么?
String monthPat = "^[1][0-2]|[0][1-9]$"
Run Code Online (Sandbox Code Playgroud)