the asterisk in tf.gather_nd in python2.7 rise syntax error

后端 未结 2 1178
小蘑菇
小蘑菇 2021-01-21 08:35

I am using Python2.7, and I can\'t update it, and I have this line of code, which raise an error at the asterisk, and I don\'t know why? And how to fix!

inp = tf.         


        
2条回答
  •  盖世英雄少女心
    2021-01-21 08:53

    That asterisk syntax is not available in Python 2. It was added in Python 3.5 (PEP 448) which was 7 years ago.

    The Python 2 equivalent was

    o = tf.gather_nd(inp, [(i,j) for (i,j) in enumerate(am)])
    

    But you really should not be using Python 2 or investing time in learning it. You don't have to "update" your existing Python 2 installation, if you need it to run legacy code. You can have Python 3.8 running side-by-side with Python 2 if you want. For work reasons I have 3.8, 3.7, 3.6 and 2.7 side-by-side on my machine without problems.

提交回复
热议问题