有没有办法把这个放在一条线上:
> ipython
Python 3.11.1 (main, Jan 24 2023, 17:02:06) [Clang 14.0.0 (clang-1400.0.29.202)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: l = ! ls
In [2]: l[:3]
Out[2]: ['___x.ipynb', 'data', 'e.txt']
In [3]: l = (! ls)[:3]
Cell In[3], line 1
l = (! ls)[:3]
^
SyntaxError: invalid syntax
?
参考:https://jakevdp.github.io/PythonDataScienceHandbook/01.05-ipython-and-shell-commands.html