关于 * 的用法

今天用 re.findall()返回的是一个List,我想取前几个元素

  于是: 

  print(*re.findall('^[+-]?\d+',str.lstrip()))    # 42

  但是自己在pycharm里赋值就GG:

  b = *re.findall('[+-]?\d+',a)                       # SyntaxError: can't use starred expression here

  

  看了这篇文章以后才知道,

        

 

 

 

  https://segmentfault.com/q/1010000013637464?utm_source=index-newest

 

posted @ 2020-01-30 19:17  ChevisZhang  阅读(184)  评论(0编辑  收藏  举报