再来一个大家很熟悉的
dict={"a": "b","c": "d"}
k,v=dict.items()
print(k,v)
for k,v in dict.items():
print(k,v,end="\n")
C:\Python37\python.exe C:/Users/Administrator/PycharmProjects/Supro/lib/python_utils.py
('a', 'b') ('c', 'd')
a b
c d
Process finished with exit code 0
三目运算ssh:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.host,self.port,self.user,self.pwd)
self.ssh=ssh
stdin, stdout, stderr = self.ssh.exec_command(shell)
res,err = stdout.readlines(),stderr.readlines()
result = res if res else err
合理运用可以减少代码量