python中.py和.pyw文件的区别
2016-03-08 10:23
519 查看
网上查了下pythonw.exe是什么东西,原来它就是无窗口的python可执行程序
You can globally redirect stdout by assigning to sys.stdout:
Then the rest of your program's stdout, including print statements, will go to mylog.txt.
You can redirect the output of print to any stream. For example
Although most of the time it would be more appropriate to use python's built-in logging facilities from the
以下是摘录自百度问题的答案:
You can globally redirect stdout by assigning to sys.stdout:
import sys sys.stdout = open("mylog.txt", "w")
Then the rest of your program's stdout, including print statements, will go to mylog.txt.
You can redirect the output of print to any stream. For example
logfile = open("logfile.txt", "w") print >>logfile, "This is a log test"
Although most of the time it would be more appropriate to use python's built-in logging facilities from the
loggingmodule.
以下是摘录自百度问题的答案:
严格来说,它们之间的不同就只有一个:视窗运行它们的时候调用不同的执行档案。 视窗用 <a target=_blank href="http://lib.csdn.net/base/11" target="_blank" style="color: rgb(51, 102, 153); text-decoration: none;">python</a>.exe 运行 .py ,用 pythonw.exe 运行 .pyw 。 这纯粹是因为安装视窗版 Python 时,扩展名 .py 自动被登记为用 python.exe 运行的文件, 而 .pyw 则被登记为用 pythonw.exe 运行。 .py 和 .pyw 之间的“其它差别”全都是 python.exe 和 pythonw.exe 之间的差别。 跟 python.exe 比较起来,pythonw.exe 有以下的不同: 1)执行时不会弹出控制台窗口(也叫 DOS 窗口) 2)所有向原有的 stdout 和 stderr 的输出都无效 3)所有从原有的 stdin 的读取都只会得到 EOF .pyw 格式是被设计来运行开发完成的纯图形界面程序的。 纯图形界面程序的用户不需要看到控制台窗口。 值得一提的是,开发纯图形界面程序的时候,你可以暂时把 .pyw 改成 .py , 以便运行时能调出控制台窗口,看到所有错误信息,方便除虫。 注:唯独视窗版 Python 有 .pyw 格式。
转自:<a target=_blank target="_blank" href="http://zhidao.baidu.com/link?url=N1x_UNV1ErPhyljcLr48roMvAxO2HOCvuJL9eZPIGQ2bLjYFDTjZbEnwhhwKOvWpRhzT-TQCN7vyjK-QmLyPW_" style="color: rgb(51, 102, 153); text-decoration: none;">http://zhidao.baidu.com/link?url=N1x_UNV1ErPhyljcLr48roMvAxO2HOCvuJL9eZPIGQ2bLjYFDTjZbEnwhhwKOvWpRhzT-TQCN7vyjK-QmLyPW_</a>
相关文章推荐
- Numpy使用2
- Python自动化开发基础 函数-模块-正则-迭代器 笔记
- 使用monkeyrunner实现手机自动转账功能
- Python 点滴 I
- 【python】编程语言入门经典100例--25
- Python多线程学习
- fedora22 python3.4 django
- Learning Python(12)--pexpect模块
- python学习记录(一)
- 【翻译】Leapmotion-python开发官方文档(6)
- 启动ipython notebook(jupyter)
- python的可变类型和不可变类型
- python中的三大数据类型
- Learning FP-Growth Algorithm in Python
- python 修改指定路径的csd文件
- 详细记录python的range()函数用法
- Windows下Python第三方.whl的安装
- Python类型——数字类型
- Python基础--快速改造:基础知识
- python入门介绍及使用