无法在python 2中拆分字符串和余数

时间:2018-09-20 11:56:04

标签: python python-2.7

在python中,我有以下字符串

433 65040    9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher 

我可以根据python 3中的以下代码进行拆分:

text = " 433 65040    9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher"
pid,rss,etime,*remainder = text.split()

但是,当我在python 2.7.12中尝试相同操作时,出现SyntaxError:

In [1]: text = " 433 65040    9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher"

In [2]: a,b,c,*d = text.split()
   File "<ipython-input-2-a87c46b7bdb7>", line 1
    a,b,c,*d = text.split()
          ^
SyntaxError: invalid syntax

如何在python2中做到这一点?

0 个答案:

没有答案