Python not outputing to file when script is run in vb program
I am making a vb text editor that can run scripting code. I have successfully gotten it to run the code and show up but I would like to be able to have the output from the the c开发者_如何转开发ode redirected to a file without having to do anything to the python code. Is that possible?
This is the code I'm using to try it but it does not write anything to the file:
Shell(compiler & " """ & fileName & " "" > C:\output.txt")
the compiler is the location of python.exe in the python install folder and the file name is the file I'm running.
The problem could also be in the way I am trying to do it with the shell command.
After some more research into the the matter I found a way to make it work.
Here is the working code:
Shell("cmd.exe /c " & compiler & " """ & fileName & " "" > ""C:\output.txt"" ", vbNormalFocus)
So I am actually running the line through the command prompt which is being called by the shell function. My assumption was that shell function was using the command prompt to execute the string argument but I guess I was wrong. Also, just to note, the output file name is also surrounded by quotes which is different than my original post.
精彩评论