python去list的括号
展开全部
Hey guei,
I think now I know what you want
You mus thave a function like this
def func(*args, **argv):
......
So now, you can pass however much parameters to it.
What if you don't know have many you are gonna have when calling it?
Well, you need a list (or dict) and have to unpack it.
Just do like this:
aList = ['param1', 'param2', .... 'paramn']
func(*aList)
See, pretty easy, '*' is for unpacking in python.
Have fun
Old answer:
If you directly print a list , then the brackets are always there.
Normaly, you can print the content of a list like this
for i in aList:
print i,
print
This will print all the content with a space seperating them.
I think now I know what you want
You mus thave a function like this
def func(*args, **argv):
......
So now, you can pass however much parameters to it.
What if you don't know have many you are gonna have when calling it?
Well, you need a list (or dict) and have to unpack it.
Just do like this:
aList = ['param1', 'param2', .... 'paramn']
func(*aList)
See, pretty easy, '*' is for unpacking in python.
Have fun
Old answer:
If you directly print a list , then the brackets are always there.
Normaly, you can print the content of a list like this
for i in aList:
print i,
This will print all the content with a space seperating them.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给点例子,不是很明白你的意思
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询