我有这样的功能:
import os
import subprocess
def find_remote_files(hostspec):
cmdline = ["rsync", "-e", "ssh", "-r", hostspec]
with open(os.devnull, "w") as devnull:
proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=devnull)
try:
for entry in proc.stdout:
items = entry.strip().split(None, 4)
if not items[0].startswith("d"):
yield items[4]
yield items[1]
yield items[2]
proc.wait()
except:
# On any exception, terminate process and re-raise exception.
proc.terminate()
proc.wait()
raise
这个函数返回三个不同的东西,我想把它存储在三个不同的变量中,比如:
a, b, c = find_remote_date('username', 'password')
# a should hold yield items[4]
# b should hold yield items[1]
# c should yield items[2]
当我尝试这样做时出现以下错误:
ValueError: too many values to unpack