Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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'


Ïà¹ØÎĵµ£º

´©Ô½Python Challenge£¨0

Ò»¸öÓÐȤµÄÍøÕ¾£º
http://www.pythonchallenge.com/
¼¯ÓéÀÖÓëѧϰÓÚÒ»Ì壬ÔÚ¿ª¶¯ÄԽ¹ØµÄ¹ý³ÌÖУ¬²»µ«À©Õ¹ÁË˼ά£¬»¹¶ÔPython¼ÓÉîÁËÀí½â¡£
Ò»¹²33¹Ø£¬Ã¿´³¹ýÒ»¹Ø¶¼¿ÉÒÔÔÚÌáʾϲ鿴×÷Õ߸ø³öµÄSolution¡£
µÚ0¹Ø£¨Ö¸µ¼¹Ø£©£º
    ³öÏÖÒ»·ù»­Ã棬ÉÏÃæд×Å2**38£¬½ÌÄãÈçºÎ½øÈëÏÂÒ»¹Ø¡£  
&nb ......

python time ×Ö·û´®×ªUTC

½ñÌìÓöµ½Ò»¸öÒ»¸öÎÊÌ⣬Êǽ«×Ö·û´®ÀàÐ͵Äʱ¼äת»¯ÎªUTCʱ¼ä¡£ÀýÈçtime_str = "2009/11/09 12:23:23" ת»¯ÎªUTC intÐÍ¡£
ÕÒÁËһЩ×ÊÁÏ£¬·¢ÏÖtimeÄ£¿é¾ÍÄÜÍê³ÉÕâ¸öת»»¡£
import time
time_str = "2009/11/09 12:23:23"
time_s = time.strptime(time_str,"%Y/%m/%d %H:%M:%S")
utc_f = time.mktime(time_s)
utc_i = int ......

ÔÚPythonÖж¯Ì¬°ó¶¨property

 ÔÚPythonÖпÉÒÔ°Ñproperty¶¯Ì¬µÄ°ó¶¨µÄobjectµÄ¼Ì³ÐÀàÖУ¬²¢ÇÒ¿ÉÒÔ¶¨Òå´øÓвÎÊýµÄgetºÍset·½·¨¡£
±ÈÈ磬ÎÒÃǶ¨ÒåÁËÈ«¾Ö±äÁ¿g£¬È»ºóͨ¹ýÁ½¸ö·½·¨À´´æÈ¡gµÄÄÚÈÝ
def get_g(self):
    return g
def set_g(self, _g):
    global g
    g = _g
¶¨ÒåÒ»¸öobjectµÄ¼Ì³ ......

python º¯Êý

PythonÖк¯Êý²ÎÊýµÄ´«µÝÊÇͨ¹ý“¸³Öµ”À´´«µÝµÄ¡£µ«ÕâÌõ¹æÔòÖ»»Ø´ðÁ˺¯Êý²ÎÊý´«µÝµÄ“Õ½ÂÔÎÊÌ┣¬²¢Ã»Óлشð“Õ½ÊõÎÊÌ┣¬Ò²¾Í˵ûÓлشðÔõô¸³ÖµµÄÎÊÌâ¡£º¯Êý²ÎÊýµÄʹÓÿÉÒÔ·ÖΪÁ½¸ö·½Ã棬һÊǺ¯Êý²ÎÊýÈçºÎ¶¨Ò壬¶þÊǺ¯ÊýÔÚµ÷ÓÃʱµÄ²ÎÊýÈçºÎ½âÎöµÄ¡£¶øºóÕßÓÖÊÇÓÉÇ°Õß¾ö¶¨µÄ¡£º¯Êý²ÎÊýµÄ¶¨ ......

PEP 0263 Defining Python Source Code Encodings

 
PEP 0263
Defining Python Source Code Encodings
Python will default to ASCII as standard encoding if no other
encoding hints are given.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, suc ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ