我想知道我是在冬天还是夏天.我目前的做法是:
if date +%Z | grep -e CET -e EST; then
# I'm in winter time
else
# I'm in summer time
fi
Run Code Online (Sandbox Code Playgroud)
这有明显的缺点,因为你必须知道所有的时区名称.
我试图在Ansible(ansible-2.1.1.0-1.fc24.noarch)剧本中的一个变量中"清理"空格,我虽然我先拆分()然后再加入('').由于某种原因,这种方法给我以下错误: - /
---
- hosts: all
remote_user: root
vars:
mytext: |
hello
there how are
you?
tasks:
- debug:
msg: "{{ mytext }}"
- debug:
msg: "{{ mytext.split() }}"
- debug:
msg: "{{ mytext.split().join(' ') }}"
...
Run Code Online (Sandbox Code Playgroud)
给我:
TASK [debug] *******************************************************************
ok: [192.168.122.193] => {
"msg": "hello\nthere how are\nyou?\n"
}
TASK [debug] *******************************************************************
ok: [192.168.122.193] => {
"msg": [
"hello",
"there",
"how",
"are",
"you?"
]
}
TASK [debug] *******************************************************************
fatal: [192.168.122.193]: FAILED! => {"failed": true, …Run Code Online (Sandbox Code Playgroud) 如何转换以下基本SMTP服务器使用smtpd一个使用aiosmtpd呢?
import smtpd
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
myqueue.queue.put(data)
self.server = CustomSMTPServer(('127.0.0.1', 10025), None)
Run Code Online (Sandbox Code Playgroud)