Discuss / Python / 在linux中,如果将默认的python改成python3?

在linux中,如果将默认的python改成python3?

Topic source

chgnhm

#1 Created at ... [Delete] [Delete and Lock User]

这个程序这么运行:

[~@localhost Python]$ ./list.py

会出现如下错误:

./list.py: line 4: syntax error near unexpected token L[0][0]' ./list.py: line 4:print(L[0][0])'

这样运行: [~@localhost Python]$ python3 list.py

结果很正常:

Apple Python Lisa

程序如下:

-- coding:utf-8 --

L=[['Apple','Google','Microsoft'],['Java','Python','Ruby','PHP'],['Adam','Bart','Lisa']]

Print Apple

print(L[0][0])

Print Python:

print(L[1][1])

Print Lisa

print(L[2][2])


  • 1

Reply