[英]Need to return file path from function and pass it as argument to another function
[英]pass the multiple return values from one function to another function as an argument
我有下面的代碼,
def hello(start, end):
perform some function
for i in range(j):
yield (some value)
yield (some value)
def calc(start, end):
start = "x"
end = "y"
for d in hello(start, end):
perform some function
data = 123
perform some function
data1 = 456
return data, data1
def world(hello()):
with open(r"C:\filepath\abc.json",'w') as file:
json.dump(hello.data, file)
with open(r"C:\filepath\abc.json") as file1:
d = json.load(file1)
return d
我怎么能那樣做?
*
運算符解壓縮返回值。 以下示例適用於我:def func1():
return 10, 's10'
def func2(code, codeString):
print("code: ", code)
return codeString
cs = func2(*func1())
print("Code string: ", cs)
有關詳細信息,請參閱元組 function arguments 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.