python的exe文件在哪,如何在Python中运行.exe文件

I am trying to run a .exe file in python2.7. I have tried everything I could from searching it. Here are some code I have tried:

subprocess.Popen(r"C:\Programs Files\Internet Explorer\iexplore.exe")

And:

subprocess.Popen(["cmd","/c",r"C:\Programs Files\Internet Explorer\iexplore.exe"])

And:

os.popen(r"C:\Programs Files\Internet Explorer\iexplore.exe")

All except the first one(which brings up a Windows Error) do not seem to run iexplore.exe.

Is there another way to run an .exe file?

解决方案

As Thomas explained in a comment, C:\Programs Files is not a standard directory on Windows. You could, of course, create a directory with that name, but it's unlikely that you've done so. Most likely you wanted C:\Program Files (notice Program vs. Programs).

The best way to avoid problems like this is to open the folder in Explorer, turn on the address bar, and copy and paste the path directly into your code. Then you'll know it's correct.

Also, you really should look at what the WindowsError says. It will almost certainly have some text about not being able to find such a file. Even if that doesn't help you, it would help people trying to solve your problem for you on a site like SO.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值