How to display file on the screen in python ?
Note:
I don't want to open for read or write, i want to display the file on the screen, like i double click on the file himself and it's open .
Thank you.
How to display file on the screen in python ?
Note:
I don't want to open for read or write, i want to display the file on the screen, like i double click on the file himself and it's open .
Thank you.
在 Windows 中,仅执行文件有效:
import os
os.system('c:/tmp/sample.txt')
基于SO
有UNIX
一个enviroment
名为的变量EDITOR
,您可以执行以下操作:
import os
import subprocess
try:
subprocess.call([os.environ['EDITOR'], 'filename'])
except:
try:
subprocess.call(['gedit', 'filename'])
except:
subprocess.call(['nano', 'filename'])