print(*(time.localtime()))中字符‘*’起什么作用?

Johnson518 2013-05-29 10:25:40
我在8.1.8. strftime() and strptime() Behavior中看到
datetime.strptime(date_string, format) is equivalent to
datetime(*(time.strptime(date_string, format)[0:6]))
不知道字符'*'在表达式中的用途。
...全文
154 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Johnson518 2013-05-29
  • 打赏
  • 举报
回复
知道了,谢谢
panghuhu250 2013-05-29
  • 打赏
  • 举报
回复
func(*arg)的意思是把arg(一个list或其他?)的元素作为参数传给func。

In [188]: def f(x, y):
     ...:     print 'x =', x, ',' 'y =', y
     ...:     

In [189]: f(1,2)
x = 1 ,y = 2

In [190]: f(*[1,2])
x = 1 ,y = 2

In [191]: f(*(1,2))
x = 1 ,y = 2

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧