gpt4 book ai didi

python - 在 IPython 中禁用通配符扩展?

转载 作者:行者123 更新时间:2023-11-30 23:21:11 25 4
gpt4 key购买 nike

有人知道在 IPython 中禁用通配符扩展的方法吗?

例如,使用 Python 3/IPython 2.1.0,如果能够使用如下所示的内容来 %run%debug 脚本,那就太好了:

%run script.py "files1*.txt" "files2*.txt"

在 IPython 之外运行相同的命令可以正常工作,但是,IPython 会自动扩展通配符表达式,即使它们用引号引起来,从而导致一长串输入参数。

如果能够在 IPython 中进行调试,那就太好了,但这使得在这个特定场景中变得很困难。知道是否可以禁用通配符扩展吗?

最佳答案

%run 的内联 ? 文档说:

Arguments are expanded using shell-like glob match. Patterns '*', '?', '[seq]' and '[!seq]' can be used. Additionally, tilde '~' will be expanded into user's home directory. Unlike real shells, quotation does not suppress expansions. Use two back slashes (e.g. \\*) to suppress expansions. To completely disable these expansions, you can use -G flag.

因此,要么使用 -G 标志,要么使用双反斜杠转义 *

您可以使用 the full docs on the run magic 在线查看相同的文档(格式不同) .

关于python - 在 IPython 中禁用通配符扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25065197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com