2005年07月08日 星期五 17:29
例如: 定义时func(a,b,c) 调用时func(a)或func(a,b)呢. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050708/f1735197/attachment.html
2005年07月08日 星期五 17:33
必输参数不能省,不定参数前面加*,如: func(a, *args) 这样可以使用 func(a) func(a, b) func(a, b, c) ... 进行调用 在 05-7-8,guqi<guqi at oasisnet.com.cn> 写道: > > 例如: > 定义时func(a,b,c) > > 调用时func(a)或func(a,b)呢. > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年07月08日 星期五 17:43
On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: > > 例如: > 定义时func(a,b,c) > > 调用时func(a)或func(a,b)呢. 用缺省参数或者不定长参数列表 请看python自带的教程里4.7节"More on Defining Functions" http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 -- Qiangning Hong I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since I'm hooked to that, all IDEs I've used so far have failed to impress me. -- Sybren Stuvel @ c.l.python Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1>
2005年07月11日 星期一 00:38
给个简单一点的例子. ----- Original Message ----- From: "Qiangning Hong" <hongqn at gmail.com> To: <python-chinese at lists.python.cn> Sent: Friday, July 08, 2005 5:43 PM Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: > > > > 例如: > > 定义时func(a,b,c) > > > > 调用时func(a)或func(a,b)呢. > > 用缺省参数或者不定长参数列表 > 请看python自带的教程里4.7节"More on Defining Functions" > http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 > > -- > Qiangning Hong > > I'm usually annoyed by IDEs because, for instance, they don't use VIM > as an editor. Since I'm hooked to that, all IDEs I've used so far have > failed to impress me. > -- Sybren Stuvel @ c.l.python > > Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> > -------------------------------------------------------------------------------- > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese >
2005年07月11日 星期一 02:00
用缺省函数: def func(a, b=1, c=2): print a, b, c func(5) 输出 5 1 2 func(5, 3) 输出 5 3 2 func(5, 3, 4) 输出 5 3 4 用不定长参数列表 def func(a, *args): print a, args func(5) 输出 5 () func(5, 3) 输出 5 (3,) func(5, 3, 4) 输出 5 (3, 4) guqi wrote: > 给个简单一点的例子. > > ----- Original Message ----- > From: "Qiangning Hong" <hongqn at gmail.com> > To: <python-chinese at lists.python.cn> > Sent: Friday, July 08, 2005 5:43 PM > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > >>On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: >> >>> >>>例如: >>>定义时func(a,b,c) >>> >>>调用时func(a)或func(a,b)呢. >> >>用缺省参数或者不定长参数列表 >>请看python自带的教程里4.7节"More on Defining Functions" >>http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 >> >>-- >>Qiangning Hong >> >>I'm usually annoyed by IDEs because, for instance, they don't use VIM >>as an editor. Since I'm hooked to that, all IDEs I've used so far have >>failed to impress me. >> -- Sybren Stuvel @ c.l.python >> >>Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> >> > > > -------------------------------------------------------------------------------- > > > >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese -- Qiangning
2005年07月11日 星期一 09:30
建议使用 用缺省函数: def func(a, b=1, c=2): print a, b, c func(5) 输出 5 1 2 func(5, 3) 输出 5 3 2 func(5, 3, 4) 输出 5 3 4 这样的做法。 在 05-7-11,Qiangning Hong<hongqn at gmail.com> 写道: > 用缺省函数: > > def func(a, b=1, c=2): > print a, b, c > > func(5) 输出 5 1 2 > func(5, 3) 输出 5 3 2 > func(5, 3, 4) 输出 5 3 4 > > > 用不定长参数列表 > > def func(a, *args): > print a, args > > func(5) 输出 5 () > func(5, 3) 输出 5 (3,) > func(5, 3, 4) 输出 5 (3, 4) > > > guqi wrote: > > 给个简单一点的例子. > > > > ----- Original Message ----- > > From: "Qiangning Hong" <hongqn at gmail.com> > > To: <python-chinese at lists.python.cn> > > Sent: Friday, July 08, 2005 5:43 PM > > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > > > > > >>On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: > >> > >>> > >>>例如: > >>>定义时func(a,b,c) > >>> > >>>调用时func(a)或func(a,b)呢. > >> > >>用缺省参数或者不定长参数列表 > >>请看python自带的教程里4.7节"More on Defining Functions" > >>http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 > >> > >>-- > >>Qiangning Hong > >> > >>I'm usually annoyed by IDEs because, for instance, they don't use VIM > >>as an editor. Since I'm hooked to that, all IDEs I've used so far have > >>failed to impress me. > >> -- Sybren Stuvel @ c.l.python > >> > >>Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> > >> > > > > > > -------------------------------------------------------------------------------- > > > > > > > >>_______________________________________________ > >>python-chinese list > >>python-chinese at lists.python.cn > >>http://python.cn/mailman/listinfo/python-chinese > > > -- > Qiangning > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- 梅劲松
2005年07月11日 星期一 10:33
有人提供用*args,这是如何使用的呢. ----- Original Message ----- From: "梅劲松" <stephen.cn at gmail.com> To: <python-chinese at lists.python.cn> Sent: Monday, July 11, 2005 9:30 AM Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > 建议使用 > 用缺省函数: > > def func(a, b=1, c=2): > print a, b, c > > func(5) 输出 5 1 2 > func(5, 3) 输出 5 3 2 > func(5, 3, 4) 输出 5 3 4 > > 这样的做法。 > > 在 05-7-11,Qiangning Hong<hongqn at gmail.com> 写道: > > 用缺省函数: > > > > def func(a, b=1, c=2): > > print a, b, c > > > > func(5) 输出 5 1 2 > > func(5, 3) 输出 5 3 2 > > func(5, 3, 4) 输出 5 3 4 > > > > > > 用不定长参数列表 > > > > def func(a, *args): > > print a, args > > > > func(5) 输出 5 () > > func(5, 3) 输出 5 (3,) > > func(5, 3, 4) 输出 5 (3, 4) > > > > > > guqi wrote: > > > 给个简单一点的例子. > > > > > > ----- Original Message ----- > > > From: "Qiangning Hong" <hongqn at gmail.com> > > > To: <python-chinese at lists.python.cn> > > > Sent: Friday, July 08, 2005 5:43 PM > > > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > > > > > > > > > >>On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: > > >> > > >>> > > >>>例如: > > >>>定义时func(a,b,c) > > >>> > > >>>调用时func(a)或func(a,b)呢. > > >> > > >>用缺省参数或者不定长参数列表 > > >>请看python自带的教程里4.7节"More on Defining Functions" > > >>http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 > > >> > > >>-- > > >>Qiangning Hong > > >> > > >>I'm usually annoyed by IDEs because, for instance, they don't use VIM > > >>as an editor. Since I'm hooked to that, all IDEs I've used so far have > > >>failed to impress me. > > >> -- Sybren Stuvel @ c.l.python > > >> > > >>Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> > > >> > > > > > > > > > -------------------------------------------------------------------------------- > > > > > > > > > > > >>_______________________________________________ > > >>python-chinese list > > >>python-chinese at lists.python.cn > > >>http://python.cn/mailman/listinfo/python-chinese > > > > > > -- > > Qiangning > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > > > > -- > 梅劲松 > -------------------------------------------------------------------------------- > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese >
2005年07月11日 星期一 10:56
*args是任意长的参数。 在 05-7-11,guqi<guqi at oasisnet.com.cn> 写道: > 有人提供用*args,这是如何使用的呢. > > ----- Original Message ----- > From: "梅劲松" <stephen.cn at gmail.com> > To: <python-chinese at lists.python.cn> > Sent: Monday, July 11, 2005 9:30 AM > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > > 建议使用 > > 用缺省函数: > > > > def func(a, b=1, c=2): > > print a, b, c > > > > func(5) 输出 5 1 2 > > func(5, 3) 输出 5 3 2 > > func(5, 3, 4) 输出 5 3 4 > > > > 这样的做法。 > > > > 在 05-7-11,Qiangning Hong<hongqn at gmail.com> 写道: > > > 用缺省函数: > > > > > > def func(a, b=1, c=2): > > > print a, b, c > > > > > > func(5) 输出 5 1 2 > > > func(5, 3) 输出 5 3 2 > > > func(5, 3, 4) 输出 5 3 4 > > > > > > > > > 用不定长参数列表 > > > > > > def func(a, *args): > > > print a, args > > > > > > func(5) 输出 5 () > > > func(5, 3) 输出 5 (3,) > > > func(5, 3, 4) 输出 5 (3, 4) > > > > > > > > > guqi wrote: > > > > 给个简单一点的例子. > > > > > > > > ----- Original Message ----- > > > > From: "Qiangning Hong" <hongqn at gmail.com> > > > > To: <python-chinese at lists.python.cn> > > > > Sent: Friday, July 08, 2005 5:43 PM > > > > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > > > > > > > > > > > > > >>On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: > > > >> > > > >>> > > > >>>例如: > > > >>>定义时func(a,b,c) > > > >>> > > > >>>调用时func(a)或func(a,b)呢. > > > >> > > > >>用缺省参数或者不定长参数列表 > > > >>请看python自带的教程里4.7节"More on Defining Functions" > > > >>http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 > > > >> > > > >>-- > > > >>Qiangning Hong > > > >> > > > >>I'm usually annoyed by IDEs because, for instance, they don't use VIM > > > >>as an editor. Since I'm hooked to that, all IDEs I've used so far have > > > >>failed to impress me. > > > >> -- Sybren Stuvel @ c.l.python > > > >> > > > >>Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> > > > >> > > > > > > > > > > > > -------------------------------------------------------------------------------- > > > > > > > > > > > > > > > >>_______________________________________________ > > > >>python-chinese list > > > >>python-chinese at lists.python.cn > > > >>http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > -- > > > Qiangning > > > _______________________________________________ > > > python-chinese list > > > python-chinese at lists.python.cn > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > -- > > 梅劲松 > > > > > -------------------------------------------------------------------------------- > > > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年07月11日 星期一 11:21
给个例子先.. ----- Original Message ----- From: "limodou" <limodou at gmail.com> To: <python-chinese at lists.python.cn> Sent: Monday, July 11, 2005 10:56 AM Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > *args是任意长的参数。 > > 在 05-7-11,guqi<guqi at oasisnet.com.cn> 写道: > > 有人提供用*args,这是如何使用的呢. > > > > ----- Original Message ----- > > From: "梅劲松" <stephen.cn at gmail.com> > > To: <python-chinese at lists.python.cn> > > Sent: Monday, July 11, 2005 9:30 AM > > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > > > > > 建议使用 > > > 用缺省函数: > > > > > > def func(a, b=1, c=2): > > > print a, b, c > > > > > > func(5) 输出 5 1 2 > > > func(5, 3) 输出 5 3 2 > > > func(5, 3, 4) 输出 5 3 4 > > > > > > 这样的做法。 > > > > > > 在 05-7-11,Qiangning Hong<hongqn at gmail.com> 写道: > > > > 用缺省函数: > > > > > > > > def func(a, b=1, c=2): > > > > print a, b, c > > > > > > > > func(5) 输出 5 1 2 > > > > func(5, 3) 输出 5 3 2 > > > > func(5, 3, 4) 输出 5 3 4 > > > > > > > > > > > > 用不定长参数列表 > > > > > > > > def func(a, *args): > > > > print a, args > > > > > > > > func(5) 输出 5 () > > > > func(5, 3) 输出 5 (3,) > > > > func(5, 3, 4) 输出 5 (3, 4) > > > > > > > > > > > > guqi wrote: > > > > > 给个简单一点的例子. > > > > > > > > > > ----- Original Message ----- > > > > > From: "Qiangning Hong" <hongqn at gmail.com> > > > > > To: <python-chinese at lists.python.cn> > > > > > Sent: Friday, July 08, 2005 5:43 PM > > > > > Subject: Re: [python-chinese] 如何写出具有可变参数的函数 > > > > > > > > > > > > > > > > > > > >>On 7/8/05, guqi <guqi at oasisnet.com.cn> wrote: > > > > >> > > > > >>> > > > > >>>例如: > > > > >>>定义时func(a,b,c) > > > > >>> > > > > >>>调用时func(a)或func(a,b)呢. > > > > >> > > > > >>用缺省参数或者不定长参数列表 > > > > >>请看python自带的教程里4.7节"More on Defining Functions" > > > > >>http://www.python.org/doc/2.4.1/tut/node6.html#SECTION006700000000000000000 > > > > >> > > > > >>-- > > > > >>Qiangning Hong > > > > >> > > > > >>I'm usually annoyed by IDEs because, for instance, they don't use VIM > > > > >>as an editor. Since I'm hooked to that, all IDEs I've used so far have > > > > >>failed to impress me. > > > > >> -- Sybren Stuvel @ c.l.python > > > > >> > > > > >>Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> > > > > >> > > > > > > > > > > > > > > > -------------------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > >>_______________________________________________ > > > > >>python-chinese list > > > > >>python-chinese at lists.python.cn > > > > >>http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > -- > > > > Qiangning > > > > _______________________________________________ > > > > python-chinese list > > > > python-chinese at lists.python.cn > > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > -- > > > 梅劲松 > > > > > > > > > -------------------------------------------------------------------------------- > > > > > > > _______________________________________________ > > > python-chinese list > > > python-chinese at lists.python.cn > > > http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > -- > I like python! > My Donews Blog: http://www.donews.net/limodou > New Google Maillist: http://groups-beta.google.com/group/python-cn > -------------------------------------------------------------------------------- > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese >
Zeuux © 2025
京ICP备05028076号