eat python 003
Documentation for C's fopen():
---
r Open text file for reading. The stream is positioned at the beginning
of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing. The
stream is positioned at the beginning of the file.
w+ Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated. The stream is positioned at the
beginning of the file.
a Open for writing. The file is created if it does not exist. The stream
is positioned at the end of the file.
a+ Open for reading and writing. The file is created if it does not
exist. The stream is positioned at the end of the file.
======================================================
In Python: http://docs.python.org/library/functions.html#open
Modes 'r+'
, 'w+'
and 'a+'
open the file for updating (note that
'w+'
truncates the file). Append 'b'
to the mode to open the file in
binary mode, on systems that differentiate between binary and text files; on
systems that don’t have this distinction, adding the 'b'
has no effect.
In addition to the standard fopen()
values mode
may be 'U'
or
'rU'
. Python is usually built with universal newline support; supplying
'U'
opens the file as a text file, but lines may be terminated by any of the
following: the Unix end-of-line convention '\n'
, the Macintosh convention
'\r'
, or the Windows convention '\r\n'
. All of these external
representations are seen as '\n'
by the Python program. If Python is built
without universal newline support a mode
with 'U'
is the same as normal
text mode. Note that file objects so opened also have an attribute called
newlines
which has a value of None
(if no newlines have yet been
seen), '\n'
, '\r'
, '\r\n'
, or a tuple containing all the newline
types seen.
Python enforces that the mode, after stripping 'U'
, begins with 'r'
,
'w'
Ïà¹ØÎĵµ£º
ÔÎÄ£ºhttp://www.klipdas.com/blog/?p=python-decorator
python×°ÊÎÆ÷½éÉÜ
Python 2.2ÖÐÒýÈëµÄ classmethod() ºÍ staticmethod() ÄÚÖú¯Êý£¬Äã¿ÉÒÔÕâÑùµ÷ÓÃclassmethod()£º
class A:
def foo(self, y):
print y
foo = classmethod(foo)
Ò²¿ÉÒÔÕâÑù£º
class A:
@classmethod
def foo(sel ......
Ò»¸öÓÐȤµÄÍøÕ¾£º
http://www.pythonchallenge.com/
¼¯ÓéÀÖÓëѧϰÓÚÒ»Ì壬ÔÚ¿ª¶¯ÄԽ¹ØµÄ¹ý³ÌÖУ¬²»µ«À©Õ¹ÁË˼ά£¬»¹¶ÔPython¼ÓÉîÁËÀí½â¡£
Ò»¹²33¹Ø£¬Ã¿´³¹ýÒ»¹Ø¶¼¿ÉÒÔÔÚÌáʾϲ鿴×÷Õ߸ø³öµÄSolution¡£
µÚ0¹Ø£¨Ö¸µ¼¹Ø£©£º
³öÏÖÒ»·ù»Ã棬ÉÏÃæÐ´×Å2**38£¬½ÌÄãÈçºÎ½øÈëÏÂÒ»¹Ø¡£
&nb ......
You are here: Home ‣ Dive Into Python 3 ‣
Difficulty level: ♦♢♢♢♢
Installing Python °²×°Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
— ancient Roman proverb
D ......
ÔÚpythonÖÐÈçºÎ´´½¨Ò»¸öÏ̶߳ÔÏó
Èç¹ûÄãÒª´´½¨Ò»¸öÏ̶߳ÔÏ󣬺ܼòµ¥£¬Ö»ÒªÄãµÄÀà¼Ì³Ðthreading.Thread£¬È»ºóÔÚ__init__ÀïÊ×Ïȵ÷ÓÃthreading.ThreadµÄ__init__·½·¨¼´¿É
import threading
class mythread(threading.Thread):
def __init__(self, threadname):
& ......
Ò¹ÀïÓÃÍâ¹ÒÈÝÒ×±»²é£¬Òò´ËÏëÈòËÊìµÄʱ¼ä¼¯Öе½°×Ì죬ÿ´Î¶¼Òª¿ÚË㣬Âé·³£¬ÕýºÃ¸Õ¸ÕѧÁËwxPython£¬Ò»Ê±ÊÖÑ÷£¬À´×Ô¼ºÐ´¸ö°É¡£Ëä˵´¿Êô×ÔÓé×ÔÀÖ£¬µ«Ò²Ñ§µ½²»ÉÙ¶«Î÷¡£ÏÖ¼ÇÓÚÏ¡£
1. ¹ØÓÚPythonµÄGUIÉè¼Æ
Ò»Ö±ÒÔÀ´¶¼Ã»ÓÐÒ»¸ö×ã¹»ºÃµÄKiller IDE£¬ÕâÒ²¹Ö²»µÃ£¬Ã»ÓÐÒ»¸ö×㹻ǿ´óµÄºǫ́£¬ÒªÏë×ö³ÉÖØÁ¿¼¶µÄIDE̸ºÎÈÝÒ×£¨ÒªÊ ......