【发布时间】:2014-01-20 22:54:48
【问题描述】:
是否可以以列表的形式输入函数的参数。 例如 -
list1 = ["somethin","some"]
def paths(list):
import os
path = os.path.join() #I want to enter the parameters of this function from the list1
return path
好的,我得到了答案,但只是一个附加问题,仅与此相关 - 这是我的代码 -
def files_check(file_name,sub_directories):
"""
file_name :The file to check
sub_directories :If the file is under any other sub directory other than the application , this is a list.
"""
appname = session.appname
if sub_directories:
path = os.path.join("applications",
appname,
*sub_directories,
file_name)
return os.path.isfile(path)
else:
path = os.path.join("applications",
appname,
file_name)
return os.path.isfile(path)
我收到此错误 -
SyntaxError: only named arguments may follow *expression
请帮帮我。
【问题讨论】:
标签: python list function parameters