Python 如何从上下文菜单中打开CMD,并将文件名作为升华文本3上CMD的输出?

Python 如何从上下文菜单中打开CMD,并将文件名作为升华文本3上CMD的输出?,python,batch-file,sublimetext3,sublimetext2,sublimetext,Python,Batch File,Sublimetext3,Sublimetext2,Sublimetext,事实上,我已经完成了这个答案:,它的工作很好,从右键点击打开命令在崇高的文本3 但我对这个剧本有些疑问 import os, sublime_plugin class CmdCommand(sublime_plugin.TextCommand): def run(self, edit): file_name=self.view.file_name() path=file_name.split("\\") current_driver=pat

事实上,我已经完成了这个答案:,它的工作很好,从右键点击打开命令在崇高的文本3

但我对这个剧本有些疑问

import os, sublime_plugin
class CmdCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        file_name=self.view.file_name()
        path=file_name.split("\\")
        current_driver=path[0]
        path.pop()
        current_directory="\\".join(path)
        command= "cd "+current_directory+" & "+current_driver+" & start cmd"
        os.system(command)
在cmd输出中从self file打开cmd时,如何获取当前文件的文件名

使用上面的脚本打开的cmd基本上如下所示:

C:\Users\myuser\Desktop>
C:\Users\myuser\Desktop>php myfile.php
C:\Users\myuser\Desktop>php myfile.php IcanTypingArg1 IcanTypingArg2
如何生成如下打开的cmd输出:

C:\Users\myuser\Desktop>
C:\Users\myuser\Desktop>php myfile.php
C:\Users\myuser\Desktop>php myfile.php IcanTypingArg1 IcanTypingArg2
或:

因此,我可以在不键入“php myfile.php”的情况下运行脚本

另一个原因是,如果我的脚本是require arguments,当cmd显示时,我只需键入参数,如下所示:

C:\Users\myuser\Desktop>
C:\Users\myuser\Desktop>php myfile.php
C:\Users\myuser\Desktop>php myfile.php IcanTypingArg1 IcanTypingArg2
然后按enter键运行此脚本

有人能帮我解决这个问题吗

我为我的英语感到抱歉。

使用repo,按
Ctrl-Alt D
使用repo,按
Ctrl-Alt D