<p><code>SList</code>有许多属性,它们以各种形式返回它:</p>
<p><a href="https://gist.github.com/parente/b6ee0efe141822dfa18b6feeda0a45e5" rel="nofollow noreferrer">https://gist.github.com/parente/b6ee0efe141822dfa18b6feeda0a45e5</a></p>
<pre><code>In [151]: ret = !ls *.json
In [152]: ret
Out[152]: ['foo1.json', 'foo.json', 'logins.json', 'stack56532806.json']
</code></pre>
<p>作为列表</p>
<pre><code>In [153]: ret.l
Out[153]: ['foo1.json', 'foo.json', 'logins.json', 'stack56532806.json']
</code></pre>
<p>作为换行符分隔字符串:</p>
<pre><code>In [154]: ret.n
Out[154]: 'foo1.json\nfoo.json\nlogins.json\nstack56532806.json'
</code></pre>
<p>以空格分隔:</p>
<pre><code>In [155]: ret.s
Out[155]: 'foo1.json foo.json logins.json stack56532806.json'
In [156]: type(ret)
</code></pre>
<p>它的文件</p>
<pre><code>In [158]: ret?
Type: SList
String form: ['foo1.json', 'foo.json', 'logins.json', 'stack56532806.json']
Length: 4
File: /usr/local/lib/python3.6/dist-packages/IPython/utils/text.py
Docstring:
List derivative with a special access attributes.
These are normal lists, but with the special attributes:
* .l (or .list) : value as list (the list itself).
* .n (or .nlstr): value as a string, joined on newlines.
* .s (or .spstr): value as a string, joined on spaces.
* .p (or .paths): list of path objects (requires path.py package)
Any values which require transformations are computed only once and
cached.
</code></pre>