Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试在 ipython notebook 前缀中使用 ipython shell 命令,前缀为 '!" 但 ls 未被识别。之前有人遇到过这个问题吗?
PS:目的是过滤所有包含名称边缘的文件
!ls在 Windows上工作很奇怪。将!命令逐字传输到底层操作系统。因此,!ls不应该在 Windows 上工作。ls另一方面是在 IPython 中实现的,因此应该可以工作。
!ls
!
ls
即使这并不能真正回答您的问题。你为什么不简单地使用pythonic方式来实现同样的目标?你可以使用:
files = sorted(filter(lambda x:'edges' in x, os.listdir('.')), key = os.path.getsize)
获取当前目录的文件(和目录)在 'edges' 之后过滤并按大小排序。