如何使用Python 打开exel等各种文件或者应用,就用:os.startfile
来源:互联网 发布:js unselectable 编辑:程序博客网 时间:2024/06/07 17:56
python虽然可以有库打开excel文件,但这个问题不是讨论这个。
而是如何通过python 直接打开各种各样的文件或者应用。
有几种方式,os.system,subprocess.Popen,os.startfile.
先看看各个介绍:
os.system:
system(...)
system(command) -> exit_status
Execute the command (a string) in a subshell.
subprocess.Popen:
class Popen(__builtin__.object)
| Methods defined here:
|
| __del__(self, _maxint=2147483647, _active=[])
|
| __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, st
derr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, un
iversal_newlines=False, startupinfo=None, creationflags=0)
| Create new Popen instance.
os.startfile:
startfile(...)
startfile(filepath [, operation]) - Start a file with its associated
application.
When "operation" is not specified or "open", this acts like
double-clicking the file in Explorer, or giving the file name as an
argument to the DOS "start" command: the file is opened with whatever
application (if any) its extension is associated.
When another "operation" is given, it specifies what should be done with
the file. A typical operation is "print".
startfile returns as soon as the associated application is launched.
There is no option to wait for the application to close, and no way
to retrieve the application's exit status.
The filepath is relative to the current directory. If you want to use
an absolute path, make sure the first character is not a slash ("/");
the underlying Win32 ShellExecute function doesn't work if it is.
看到这块,已经很明确了,就是她了:os.startfile
如果只有路径,相当于在浏览器双击这个文件!
- 如何使用Python 打开exel等各种文件或者应用,就用:os.startfile
- [Python] Mac OS 下 os.startfile 的替代方案
- [Python] Mac OS 下 os.startfile 的替代方案
- 如何通过命令行或者使用代码打开一个apk文件
- 打开Word,PDF等文件(使用第三方应用)
- Android中如何使用代码打开各种类型的文件
- 打开各种文件,txt,pdf,jpg等
- 如何使用Office2003来打开Docx、xlsb、xlsx等文件
- xp或者win7如何打开jar文件
- 如何打开.pdm文件(Mac OS X)
- 使用C#选择文件夹、打开文件夹、选择文件或者如何使用C#选择文件夹
- Python如何打开外部文件?
- Python 如何打开.pkl文件
- C/C++/Python等 使用二进制模式打开文件与不使用二进制模式的区别
- 各种格式的文件使用工具打开
- android 使用intent 打开各种文件方式
- Android--使用Intent打开各种文件
- 使用python+selenium自动上传exel表中bug
- 最常用的SAT数学题解答方法分享
- 通用顶部自定义控件 可在XML自定义属性
- YUVtoRGB RGB to YUV color convert formulas - ITU 601
- linux 命令之tcpdump
- Java Clob类型转String类型
- 如何使用Python 打开exel等各种文件或者应用,就用:os.startfile
- 第十六周项目1-平方根中的异常
- Audio Streaming mit UDP in C
- Eclipse 中设置JVM 内存及JVM监控调优
- android listview 异步加载图片并防止错位
- 微软100题(94)找出数组中长度最长的等差数列
- Android Gradle
- 在ListView或GridView 中使用到跑马灯滚动效果实现的问题。
- java 执行bat文件