2024-05-19 07:57:34 发布
网友
我尝试使用cmd模块实现python命令。我想自动完成文件,所以我实现了一些方法,但是,我看到“complete\u put(self,text,line,begidx,endidx):”中的text参数会去除所有的'/'字符。有人知道为什么,我怎样才能避免这种行为?谢谢:)
我解决了。只需要修改set\u completer\u delims属性。在
这是我使用的代码,它基于互联网上的几个例子。在
import os import cmd import readline class Shell(cmd.Cmd, object): def __init__(self): cmd.Cmd.__init__(self) def __complete_path(self, path=None): return ['/bin', '/boot', '/etc'] def do_put(self,args): print args def complete_put(self, text, line, begidx, endidx): print text if not text: return self.__complete_path() return self.__complete_path(text)
我解决了。只需要修改set\u completer\u delims属性。在
这是我使用的代码,它基于互联网上的几个例子。在
相关问题 更多 >
编程相关推荐