Welcome to JS/Linux (x86)
Use 'vflogin username' to connect to your account.
You can create a new account at https://vfsync.org/signup .
Use 'export_file filename' to export a file to your computer.
Imported files are written to the home directory.
[root@localhost ~]# python
Python 2.7.11 (default, May 24 2017, 22:33:10)
[GCC 6.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
列表赋值
>>> aList=[123,'abc',4.56,['inner','list'],7-9j]
>>> aList
[123, 'abc', 4.5599999999999996, ['inner', 'list'], (7-9j)]
>>> anotherList=[None,'something to seee here']
>>> aList
[123, 'abc', 4.5599999999999996, ['inner', 'list'], (7-9j)]
>>> anotherList
[None, 'something to seee here']
>>> print anotherList
[None, 'something to seee here']
访问列表中的值
>>> aList[0]
123
>>> aList[1-3]
['inner', 'list']
>>> aList[1]
'abc'
>>> aList[1-2]
(7-9j)
>>> aList[1:2]
['abc']
>>> aList[1:3]
['abc', 4.5599999999999996]
>>>
>>> aList[1:4]
['abc', 4.5599999999999996, ['inner', 'list']]
>>> aList[:4]
[123, 'abc', 4.5599999999999996, ['inner', 'list']]
>>> aList[3][1]
'list'
>>> aList[3][2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>> aList[3][0]
'inner'
更新列表
>>> aList[2]='float replacer'
>>> aList[2]
'float replacer'
>>> aList
[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j)]
>>> aList.append("hi,i'm new here")
>>> aList
[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j), "hi,i'm new here"]
>>> aList.append(hi,i'm new here)
File "<stdin>", line 1
aList.append(hi,i'm new here)
^
SyntaxError: EOL while scanning string literal
>>>
>>> del aList[0]
>>> aList
['abc', 'float replacer', ['inner', 'list'], (7-9j), "hi,i'm new here"]
>>> aList.remove('abc')
>>> aList
['float replacer', ['inner', 'list'], (7-9j), "hi,i'm new here"]