易截截图软件、单文件、免安装、纯绿色、仅160KB

用Python直接写UTF 8文本文件

当我们这样建立文件时
f =
file('x1.txt', 'w')
f.write(u'中文')
f.colse()

接结果应该是类似
    f.write(u'中文')
UnicodeEncodeError: 'ascii'
codec can't encode characters in position 0-16: ordinal not in
range(128)
要直接写 utf-8 文件怎么办呢?
import codecs
f = codecs.open("pru_uni.txt", "w", "utf-8")
txt = unicode("campeón\n", "utf-8")
f.write(txt)
f.write(u'中文\n')
f.close()


相关文档:

Python TKinter Gui: Toplevel window

#from pp3e Chapter 9.3
#############################################################################
# popup three new window, with style
# destroy() kills one window, quit() kills all windows and app; top-level
# windows have title, icon, iconify/deiconify and protocol for wm events;
# there ......

python 笔记 for loop and extend, append

list.append(item)
list.extend(sequence)
http://docs.python.org/tutorial/datastructures.html
http://docs.python.org/library/functions.html 这几天看一下
python howto
恩。python documentation 确实很好很强大啊!
list.append(x)Add an item to the end of the list; equivalent to a[len(a):]&n ......

手动制作python的exe可执行程序


1. 手动制作python的exe可执行程序
                                      转载---------------
Python没有内建一个编 ......

Python Get Key press

refer from:  http://www.daniweb.com/forums/thread115282.html#
python
Syntax
(Toggle Plain Text
)

# respond to a key
without the need to press
enter
 
import
Tkinter
as tk
 
def
keypress(
event)
:
if
event.keysym
== 'Escape'
:
root.destroy
......

python中package机制的两种实现方式


当执行import
module时,解释器会根据下面的搜索路径,搜索module1.py文件。
1) 当前工作目录
2) PYTHONPATH中的目录
3) Python安装目录
(/usr/local/lib/python)
事实上,模块搜索是在保存在sys.path这个全局变量中的目录列表中进行搜索。
sys.path会在解释器开始执行时被初始化成包含:
1)当前工作目录
2) PYT ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号