Python论坛  - 讨论区

标题:[python-chinese] open函数翻译[原创]

2006年12月13日 星期三 13:00

tdus lost tdus.lost在gmail.com
星期三 十二月 13 13:00:01 HKT 2006

ÏÐÀ´ÎÞÊÂ,·­ÒëÁËÒ»ÏÂpython¹Ù·½ÎĵµµÄopenº¯Êý×ÊÁÏ:
żӢÎĺÜÀÃ,¸÷뽫¾Í×Å¿´,»¹Óм¸¾ä²»»á·­,¸ßÊÖÃÇ»¹ÇëÖ¸µãÒ»ÏÂ.


open( filename[, mode[, bufsize]])
#´ò¿ªÎļþ.
#(ÎļþÃû[,ģʽ[,»º´æ´óС]])

Open a file, returning an object of the file type described in section 3.9,
``File Objects''. If the file cannot be opened, IOError is raised. When
opening a file, it's preferable to use open() instead of invoking the file
constructor directly.
The first two arguments are the same as for stdio's fopen(): filename is the
file name to be opened, and mode is a string indicating how the file is to
be opened.

´ò¿ªÒ»¸öÎļþ,·µ»ØÒ»¸ö¶ÔÏó(ÀàÐÍÃèÊöÔÚ"Îļþ¶ÔÏó"3.9½Ú
).Èç¹ûÎļþ²»ÄÜ´ò¿ª,½«Å׳öIOError,µ±Äã´ò¿ªÒ»¸öÎļþʱ,Äã×îºÃʹÓÃopen()·½·¨¶ø²»ÊÇÖ±½Óµ÷Óù¹ÔìÆ÷.

The most commonly-used values of mode are 'r' for reading, 'w' for writing
(truncating the file if it already exists), and 'a' for appending (which on
some Unix systems means that all writes append to the end of the file
regardless of the current seek position). If mode is omitted, it defaults to
'r'. When opening a binary file, you should append 'b' to the mode value to
open the file in binary mode, which will improve portability. (Appending 'b'
is useful even on systems that don't treat binary and text files
differently, where it serves as documentation.) See below for more possible
values of mode.

´ó¶àÊýÒ»°ãʹÓÃÇé¿öÖÐ,²ÎÊý'ģʽ'µÄÖµµÄÇé¿öÊÇ'r'ÓÃÀ´¶Á,'w'ÓÃÀ´Ð´(ÈçÎļþ´æÔÚÔò¸²¸ÇÎļþ),'a'ÓÃÀ´×·¼Ó(¶ÔÎÒµÄunixϵͳ¶øÑÔ,ËùÓеÄÄÚÈݶ¼½«×·¼Óµ½Îļþĩβ¶ø²»¹Ü̽ÕëµÄµ±Ç°Î»ÖÃÈçºÎ.),Èç¹û'ģʽ'µÄֵʡÂÔ,ÔòĬÈÏΪ'r'.µ±´ò¿ªÒ»¸ö¶þ½øÖÆÎļþ,'ģʽ'µÄÖµ±ØÐëÓÃ'b',´Ë¾Ù½«¸ÄÉÆÐÔÄÜ.(Ôö¼Ó'b'ģʽÊÇÓÃÀ´¼æÈÝϵͳ¶Ôµ±¶þ½øÖƺÍÎı¾ÎļþµÄ´¦Àí²»Í¬.),Çë²Î¿¼¸ü¶àµÄ'ģʽ'Öµ.

The optional bufsize argument specifies the file's desired buffer size: 0
means unbuffered, 1 means line buffered, any other positive value means use
a buffer of (approximately) that size. A negative bufsize means to use the
system default, which is usually line buffered for tty devices and fully
buffered for other files. If omitted, the system default is used.2.3

¿ÉÑ¡'»º´æ'²ÎÊýÖ¸¶¨Îļþ»º´æ´óС:0ΪÎÞ»º³å,1ΪÐлº³å,ÈκÎÆäËûÖµ¶¼ÒÔ»º´æ´óСÀ´¶Ô´ý.Ò»¸ö²»µ±µÄ»º´æ´óСÒâζ×ÅÓÃϵͳĬÈÏÌæ´ú
,Òâ˼ÊÇͨ³£ttyÉ豸¾ÍÊÇÐлº³å,ÆäËûÎļþ¾ÍÊÇÍêÈ«»º³å,Èç¹ûÊ¡ÂÔ,½«ÏµÍ³Ä¬ÈÏ.2.3

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.

ģʽ'r+','w+'ºÍ'a+'ÒÔ¸üз½Ê½´ò¿ªÎļþ(×¢Òâ'w+'¸²¸ÇÎļþ).µ±ÏµÍ³²»Í¬µÈ¶Ô´ý¶þ½øÖÆÎļþºÍÎı¾ÎļþµÄʱ,Ôö¼Ó'b'
ģʽÒÔ¶þ½øÖÆ·½Ê½´ò¿ªÎļþ.µ±ÏµÍ³¶Ô´ýÕâÁ½ÖÖÎļþûÓвî±ðµÄʱºò,'b'ģʽÎÞЧ¹û.

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.

³ýÁ˱ê×¼fopen()ģʽֵ֮Í⻹¿ÉʹÓÃ'U' »òÕß
'rU'.python¹ßÀý¹¹ÔìÁËͨÓû»ÐÐÖ§³Ö;Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython²»¹¹ÔìÒ»¸öͨÓû»ÐÐÖ§³Öģʽ'u'À´ÓÃͳһ¶Ô´ýÕý³£Îı¾Ä£Ê½µÄ»°...²»»á·­.

Python enforces that the mode, after stripping 'U', begins with 'r', 'w' or
'a'.

pythonÇ¿ÖÆÖ´ÐдËģʽ,ÔÚ'u'֮ǰ,ÔÚ'r','w'or'a'Ö®ºó.

Changed in version 2.5: Restriction on first letter of mode string
introduced.

2.5°æ±¾µÄ¸Ä±ä:ÏÞÖƵÚÒ»¸ö×Ö·û·½Ê½´«ÈëµÄ×Ö·û
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061213/3a9e59f3/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月13日 星期三 13:11

风向标 vaneoooo在gmail.com
星期三 十二月 13 13:11:00 HKT 2006

Ö§³Ö°¡Ö§³Ö

·Ç³£Òì³£³¬¼¶³¤¸Ðлtdus lostÐÖ
ллÄãµÄ¸¶³öÓë·ÖÏí

¹þ¹þ¡£¸É´à¾ÍÒ»¹Ä×÷Æø£¬°ÑurllibºÍpilµÄ¶¼¸øÄÃÏ£¿¹þ¹þ
ÎÒºÃÌ°ÐÄ

ÔÚ06-12-13£¬tdus lost <tdus.lost在gmail.com> дµÀ£º
>
> ÏÐÀ´ÎÞÊÂ,·­ÒëÁËÒ»ÏÂpython¹Ù·½ÎĵµµÄopenº¯Êý×ÊÁÏ:
> żӢÎĺÜÀÃ,¸÷뽫¾Í×Å¿´,»¹Óм¸¾ä²»»á·­,¸ßÊÖÃÇ»¹ÇëÖ¸µãÒ»ÏÂ.
>
>
> open( filename[, mode[, bufsize]])
> #´ò¿ªÎļþ.
> #(ÎļþÃû[,ģʽ[,»º´æ´óС]])
>
> Open a file, returning an object of the file type described in section 3.9,
> ``File Objects''. If the file cannot be opened, IOError is raised. When
> opening a file, it's preferable to use open() instead of invoking the file
> constructor directly.
> The first two arguments are the same as for stdio's fopen(): filename is
> the file name to be opened, and mode is a string indicating how the file is
> to be opened.
>
> ´ò¿ªÒ»¸öÎļþ,·µ»ØÒ»¸ö¶ÔÏó(ÀàÐÍÃèÊöÔÚ"Îļþ¶ÔÏó"3.9½Ú).Èç¹ûÎļþ²»ÄÜ´ò¿ª,½«Å׳öIOError,µ±Äã´ò¿ªÒ»¸öÎļþʱ,Äã×îºÃʹÓÃopen()·½·¨¶ø²»ÊÇÖ±½Óµ÷Óù¹ÔìÆ÷.
>
>
> The most commonly-used values of mode are 'r' for reading, 'w' for writing
> (truncating the file if it already exists), and 'a' for appending (which on
> some Unix systems means that all writes append to the end of the file
> regardless of the current seek position). If mode is omitted, it defaults to
> 'r'. When opening a binary file, you should append 'b' to the mode value to
> open the file in binary mode, which will improve portability. (Appending 'b'
> is useful even on systems that don't treat binary and text files
> differently, where it serves as documentation.) See below for more possible
> values of mode.
>
>
> ´ó¶àÊýÒ»°ãʹÓÃÇé¿öÖÐ,²ÎÊý'ģʽ'µÄÖµµÄÇé¿öÊÇ'r'ÓÃÀ´¶Á,'w'ÓÃÀ´Ð´(ÈçÎļþ´æÔÚÔò¸²¸ÇÎļþ),'a'ÓÃÀ´×·¼Ó(¶ÔÎÒµÄunixϵͳ¶øÑÔ,ËùÓеÄÄÚÈݶ¼½«×·¼Óµ½Îļþĩβ¶ø²»¹Ü̽ÕëµÄµ±Ç°Î»ÖÃÈçºÎ.),Èç¹û'ģʽ'µÄֵʡÂÔ,ÔòĬÈÏΪ'r'.µ±´ò¿ªÒ»¸ö¶þ½øÖÆÎļþ,'ģʽ'µÄÖµ±ØÐëÓÃ'b',´Ë¾Ù½«¸ÄÉÆÐÔÄÜ.(Ôö¼Ó'b'ģʽÊÇÓÃÀ´¼æÈÝϵͳ¶Ôµ±¶þ½øÖƺÍÎı¾ÎļþµÄ´¦Àí²»Í¬.),Çë²Î¿¼¸ü¶àµÄ'ģʽ'Öµ.
>
> The optional bufsize argument specifies the file's desired buffer size: 0
> means unbuffered, 1 means line buffered, any other positive value means use
> a buffer of (approximately) that size. A negative bufsize means to use the
> system default, which is usually line buffered for tty devices and fully
> buffered for other files. If omitted, the system default is used.2.3
>
> ¿ÉÑ¡'»º´æ'²ÎÊýÖ¸¶¨Îļþ»º´æ´óС:0ΪÎÞ»º³å,1ΪÐлº³å,ÈκÎÆäËûÖµ¶¼ÒÔ»º´æ´óСÀ´¶Ô´ý.Ò»¸ö²»µ±µÄ»º´æ´óСÒâζ×ÅÓÃϵͳĬÈÏÌæ´ú
> ,Òâ˼ÊÇͨ³£ttyÉ豸¾ÍÊÇÐлº³å,ÆäËûÎļþ¾ÍÊÇÍêÈ«»º³å,Èç¹ûÊ¡ÂÔ,½«ÏµÍ³Ä¬ÈÏ.2.3
>
> 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.
>
> ģʽ'r+','w+'ºÍ'a+'ÒÔ¸üз½Ê½´ò¿ªÎļþ(×¢Òâ'w+'¸²¸ÇÎļþ).µ±ÏµÍ³²»Í¬µÈ¶Ô´ý¶þ½øÖÆÎļþºÍÎı¾ÎļþµÄʱ,Ôö¼Ó'b'
> ģʽÒÔ¶þ½øÖÆ·½Ê½´ò¿ªÎļþ.µ±ÏµÍ³¶Ô´ýÕâÁ½ÖÖÎļþûÓвî±ðµÄʱºò,'b'ģʽÎÞЧ¹û.
>
> 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.
>
> ³ýÁ˱ê×¼fopen()ģʽֵ֮Í⻹¿ÉʹÓÃ'U' »òÕß
> 'rU'.python¹ßÀý¹¹ÔìÁËͨÓû»ÐÐÖ§³Ö;Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython²»¹¹ÔìÒ»¸öͨÓû»ÐÐÖ§³Öģʽ'u'À´ÓÃͳһ¶Ô´ýÕý³£Îı¾Ä£Ê½µÄ»°...²»»á·­.
>
> Python enforces that the mode, after stripping 'U', begins with 'r', 'w'
> or 'a'.
>
> pythonÇ¿ÖÆÖ´ÐдËģʽ,ÔÚ'u'֮ǰ,ÔÚ'r','w'or'a'Ö®ºó.
>
> Changed in version 2.5: Restriction on first letter of mode string
> introduced.
>
> 2.5°æ±¾µÄ¸Ä±ä:ÏÞÖƵÚÒ»¸ö×Ö·û·½Ê½´«ÈëµÄ×Ö·û
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061213/d66ff1ed/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月13日 星期三 15:23

苏亚 su1981ya在163.com
星期三 十二月 13 15:23:06 HKT 2006

tdus lost 写道:
> 闲来无事,翻译了一下python官方文档的open函数资料:
> 偶英文很烂,各位将就着看,还有几句不会翻,高手们还请指点一下.
> open( filename[, mode[, bufsize]])
> #打开文件.
> #(文件名[,模式[,缓存大小]])
最好是组建一个项目,每个人可以任意翻译其中的某些部分,提交后由大家审定,
然后发布。
小河汇流才能成为海


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月13日 星期三 17:57

Yunfeng Tao taoyfeng在gmail.com
星期三 十二月 13 17:57:23 HKT 2006

翻译这碗饭不是这么容易吃的。比如这一句:
Python is usually built with universal newline support.
你翻作"python惯例构造了通用换行支持"。简直不及机器翻译。
我试行翻译,如下:
Python通常以支持通用换行的方式编译。
我相信,肯定有更为妥贴的译法。

在 06-12-13,tdus lost<tdus.lost在gmail.com> 写道:
> 闲来无事,翻译了一下python官方文档的open函数资料:
> 偶英文很烂,各位将就着看,还有几句不会翻,高手们还请指点一下.
>
>
> open( filename[, mode[, bufsize]])
> #打开文件.
> #(文件名[,模式[,缓存大小]])
>
> Open a file, returning an object of the file type described in section 3.9,
> ``File Objects''. If the file cannot be opened, IOError is raised. When
> opening a file, it's preferable to use open() instead of invoking the file
> constructor directly.
> The first two arguments are the same as for stdio's fopen(): filename is the
> file name to be opened, and mode is a string indicating how the file is to
> be opened.
>
> 打开一个文件,返回一个对象(类型描述在"文件对象"3.9节).如果文件不能打开,将抛出IOError,当你打开一个文件时,你最好使用open()方法而不是直接调用构造器.
>
> The most commonly-used values of mode are 'r' for reading, 'w' for writing
> (truncating the file if it already exists), and 'a' for appending (which on
> some Unix systems means that all writes append to the end of the file
> regardless of the current seek position). If mode is omitted, it defaults to
> 'r'. When opening a binary file, you should append 'b' to the mode value to
> open the file in binary mode, which will improve portability. (Appending 'b'
> is useful even on systems that don't treat binary and text files
> differently, where it serves as documentation.) See below for more possible
> values of mode.
>
> 大多数一般使用情况中,参数'模式'的值的情况是'r'用来读,'w'用来写(如文件存在则覆盖文件),'a'用来追加(对我的unix系统而言,所有的内容都将追加到文件末尾而不管探针的当前位置如何.),如果'模式'的值省略,则默认为'r'.当打开一个二进制文件,'模式'的值必须用'b',此举将改善性能.(增加'b'模式是用来兼容系统对当二进制和文本文件的处理不同.),请参考更多的'模式'值.
>
> The optional bufsize argument specifies the file's desired buffer size: 0
> means unbuffered, 1 means line buffered, any other positive value means use
> a buffer of (approximately) that size. A negative bufsize means to use the
> system default, which is usually line buffered for tty devices and fully
> buffered for other files. If omitted, the system default is used.2.3
>
> 可选'缓存'参数指定文件缓存大小:0为无缓冲,1为行缓冲,任何其他值都以缓存大小来对待.一个不当的缓存大小意味着用系统默认替代,意思是通常tty设备就是行缓冲,其他文件就是完全缓冲,如果省略,将系统默认.2.3
>
> 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.
>
> 模式'r+','w+'和'a+'以更新方式打开文件(注意'w+'覆盖文件).当系统不同等对待二进制文件和文本文件的时,增加'b'模式以二进制方式打开文件.当系统对待这两种文件没有差别的时候,'b'模式无效果.
>
> 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.
>
> 除了标准fopen()模式值之外还可使用'U' 或者
> 'rU'.python惯例构造了通用换行支持;提供'U'模式以文本方式打开一个文件,但是行可能随时结束:Unix的结束符规定为'\n',苹果系统则为'\r',还有windows规定为'\r\n',所有这些规定在python程序中统一为'\n'.如果python不构造一个通用换行支持模式'u'来用统一对待正常文本模式的话...不会翻.
>
> Python enforces that the mode, after stripping 'U', begins with 'r', 'w' or
> 'a'.
>
> python强制执行此模式,在'u'之前,在'r','w'or'a'之后.
>
> Changed in version 2.5: Restriction on first letter of mode string
> introduced.
>
> 2.5版本的改变:限制第一个字符方式传入的字符
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月13日 星期三 19:14

风向标 vaneoooo在gmail.com
星期三 十二月 13 19:14:16 HKT 2006

tdus lostÐÖ
ÎÒÊǸö³¹µ×Ó¢ÎÄä°¡¡£ËäÈ»ÒѾ­ºÜŬÁ¦µÄ×ö¸Ä±ä£¬µ«ÊÇʼÖÕÀëÁ÷³©ÔĶÁÓкܴó²î¾à°¡
»¹ÊÇÓÐÀµÖîλ°ïÖú·­Òë°¡

yunfeng taoÐÖ
¸öÈ˾õµÃ·­ÒëÎĵµÕâ¸öʲ»ÓþÐÄàÓÚ¸ö±ð¾ä×ӵĺ¬Òå
±Ï¾¹¶ÔÓÚÓ¢ÎÄ䣬ÐèÒª½èÖúÓÚ·­ÒëÎĵµµÄÈËÀ´Ëµ
¸ö±ðµÄ´íÎó×ܱÈͨƪ¶¼ÊÇÓ¢ÎÄÀ´µÄÇ¿
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061213/a08ed006/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 10:32

Yunfeng Tao taoyfeng在gmail.com
星期四 十二月 14 10:32:37 HKT 2006

我同意个别的错误总比通篇都是英文来的强,如果确实只有个别错误的话。

在 06-12-13,风向标<vaneoooo在gmail.com> 写道:
> tdus lost兄
> 我是个彻底英文盲啊。虽然已经很努力的做改变,但是始终离流畅阅读有很大差距啊
> 还是有赖诸位帮助翻译啊
>
> yunfeng tao兄
> 个人觉得翻译文档这个事不用拘泥于个别句子的含义
> 毕竟对于英文盲,需要借助于翻译文档的人来说
> 个别的错误总比通篇都是英文来的强
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 10:34

Yunfeng Tao taoyfeng在gmail.com
星期四 十二月 14 10:34:04 HKT 2006

这个意见值得重视。

2006/12/13, 苏亚 <su1981ya在163.com>:
> tdus lost 写道:
> > 闲来无事,翻译了一下python官方文档的open函数资料:
> > 偶英文很烂,各位将就着看,还有几句不会翻,高手们还请指点一下.
> > open( filename[, mode[, bufsize]])
> > #打开文件.
> > #(文件名[,模式[,缓存大小]])
> 最好是组建一个项目,每个人可以任意翻译其中的某些部分,提交后由大家审定,
> 然后发布。
> 小河汇流才能成为海
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 11:01

yi huang yi.codeplayer在gmail.com
星期四 十二月 14 11:01:08 HKT 2006

On 12/13/06, 苏亚 <su1981ya at 163.com> wrote:
>
> tdus lost 写道:
> > 闲来无事,翻译了一下python官方文档的open函数资料:
> > 偶英文很烂,各位将就着看,还有几句不会翻,高手们还请指点一下.
> > open( filename[, mode[, bufsize]])
> > #打开文件.
> > #(文件名[,模式[,缓存大小]])
> 最好是组建一个项目,每个人可以任意翻译其中的某些部分,提交后由大家审定,
> 然后发布。
> 小河汇流才能成为海
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


啄木鸟就是个好地方啊:
http://wiki.woodpecker.org.cn/moin/PythonZhDoc
自己去里面加个条目,比如 python官方文档翻译 ,然后建个页面把这篇翻译放进去,再在上面那个页面里放个链接。

-- 
http://codeplayer.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20061214/708ddfa7/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 13:30

boyeestudio boyee118在gmail.com
星期四 十二月 14 13:30:21 HKT 2006

ÔÚ06-12-13£¬tdus lost <tdus.lost在gmail.com> дµÀ£º
>
> ÏÐÀ´ÎÞÊÂ,·­ÒëÁËÒ»ÏÂpython¹Ù·½ÎĵµµÄopenº¯Êý×ÊÁÏ:
> żӢÎĺÜÀÃ,¸÷뽫¾Í×Å¿´,»¹Óм¸¾ä²»»á·­,¸ßÊÖÃÇ»¹ÇëÖ¸µãÒ»ÏÂ.
>
>
> open( filename[, mode[, bufsize]])
> #´ò¿ªÎļþ.
> #(ÎļþÃû[,ģʽ[,»º´æ´óС]])
>
> Open a file, returning an object of the file type described in section 3.9,
> ``File Objects''. If the file cannot be opened, IOError is raised. When
> opening a file, it's preferable to use open() instead of invoking the file
> constructor directly.
> The first two arguments are the same as for stdio's fopen(): filename is
> the file name to be opened, and mode is a string indicating how the file is
> to be opened.
>
> ´ò¿ªÒ»¸öÎļþ,·µ»ØÒ»¸ö¶ÔÏó(ÀàÐÍÃèÊöÔÚ"Îļþ¶ÔÏó"3.9½Ú).Èç¹ûÎļþ²»ÄÜ´ò¿ª,½«Å׳öIOError,µ±Äã´ò¿ªÒ»¸öÎļþʱ,Äã×îºÃʹÓÃopen()·½·¨¶ø²»ÊÇÖ±½Óµ÷Óù¹ÔìÆ÷.
>
>
> The most commonly-used values of mode are 'r' for reading, 'w' for writing
> (truncating the file if it already exists), and 'a' for appending (which on
> some Unix systems means that all writes append to the end of the file
> regardless of the current seek position). If mode is omitted, it defaults to
> 'r'. When opening a binary file, you should append 'b' to the mode value to
> open the file in binary mode, which will improve portability. (Appending 'b'
> is useful even on systems that don't treat binary and text files
> differently, where it serves as documentation.) See below for more possible
> values of mode.
>
>
> ´ó¶àÊýÒ»°ãʹÓÃÇé¿öÖÐ,²ÎÊý'ģʽ'µÄÖµµÄÇé¿öÊÇ'r'ÓÃÀ´¶Á,'w'ÓÃÀ´Ð´(ÈçÎļþ´æÔÚÔò¸²¸ÇÎļþ),'a'ÓÃÀ´×·¼Ó(¶ÔÎÒµÄunixϵͳ¶øÑÔ,ËùÓеÄÄÚÈݶ¼½«×·¼Óµ½Îļþĩβ¶ø²»¹Ü̽ÕëµÄµ±Ç°Î»ÖÃÈçºÎ.),Èç¹û'ģʽ'µÄֵʡÂÔ,ÔòĬÈÏΪ'r'.µ±´ò¿ªÒ»¸ö¶þ½øÖÆÎļþ,'ģʽ'µÄÖµ±ØÐëÓÃ'b',´Ë¾Ù½«¸ÄÉÆÐÔÄÜ.(Ôö¼Ó'b'ģʽÊÇÓÃÀ´¼æÈÝϵͳ¶Ôµ±¶þ½øÖƺÍÎı¾ÎļþµÄ´¦Àí²»Í¬.),Çë²Î¿¼¸ü¶àµÄ'ģʽ'Öµ.
>
> The optional bufsize argument specifies the file's desired buffer size: 0
> means unbuffered, 1 means line buffered, any other positive value means use
> a buffer of (approximately) that size. A negative bufsize means to use the
> system default, which is usually line buffered for tty devices and fully
> buffered for other files. If omitted, the system default is used.2.3
>
> ¿ÉÑ¡'»º´æ'²ÎÊýÖ¸¶¨Îļþ»º´æ´óС:0ΪÎÞ»º³å,1ΪÐлº³å,ÈκÎÆäËûÖµ¶¼ÒÔ»º´æ´óСÀ´¶Ô´ý.Ò»¸ö²»µ±µÄ»º´æ´óСÒâζ×ÅÓÃϵͳĬÈÏÌæ´ú
> ,Òâ˼ÊÇͨ³£ttyÉ豸¾ÍÊÇÐлº³å,ÆäËûÎļþ¾ÍÊÇÍêÈ«»º³å,Èç¹ûÊ¡ÂÔ,½«ÏµÍ³Ä¬ÈÏ.2.3
>
> 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.
>
> ģʽ'r+','w+'ºÍ'a+'ÒÔ¸üз½Ê½´ò¿ªÎļþ(×¢Òâ'w+'¸²¸ÇÎļþ).µ±ÏµÍ³²»Í¬µÈ¶Ô´ý¶þ½øÖÆÎļþºÍÎı¾ÎļþµÄʱ,Ôö¼Ó'b'
> ģʽÒÔ¶þ½øÖÆ·½Ê½´ò¿ªÎļþ.µ±ÏµÍ³¶Ô´ýÕâÁ½ÖÖÎļþûÓвî±ðµÄʱºò,'b'ģʽÎÞЧ¹û.
>

Õâ¶Î£¬ÎÒÊÔһϣº

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.
>
> ³ýÁ˱ê×¼fopen()ģʽֵ֮Í⻹¿ÉʹÓÃ'U' »òÕß
> 'rU'.python¹ßÀý¹¹ÔìÁËͨÓû»ÐÐÖ§³Ö;Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython²»¹¹ÔìÒ»¸öͨÓû»ÐÐÖ§³Öģʽ'u'À´ÓÃͳһ¶Ô´ýÕý³£Îı¾Ä£Ê½µÄ»°...²»»á·­.
>


³ýÁ˱ê×¼µÄfopen(),ֵģʽ»¹¿ÉΪ'U'»òÕß'rU'.ͨ³££¬PythonÒÑÄÚ½¨Í³Ò»µÄ»»ÐÐÖ§³Ö£¡
Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython
ûÓÐÄÚ½¨Ò»¸öͨÓû»ÐÐÖ§³Ö,ÄÇô'U'ģʽÓëͨÓÃÎļþÄ£ÊÔûʲôÇø±ðÁË¡£×¢Ò⣬Èç´Ë´ò¿ªµÄËùÓÐÎļþ¶ÔÏóÒ²ÓÐÒ»¸ö³ÆΪ»»ÐеÄÊôÐÔ£¬ÆäֵΪNone(Èç¹û¿´²»µ½ÐÂÐоÍÊÇÕâÖÖÇé¿ö),'\n',
'\r', '\r\n',»òÕßÊÇÒ»¸ö°üº¬ËùÓпɼûµÄ»»ÐÐÀàÐ͵ÄÔª×é¡££¨×¢£ºÕâ¸öֵΪÉÏÃæËÄÖÖÖ®Ò»£©

Çë¸ßÊÖÖ¸½Ì£¡Ð»Ð»£¡

Python enforces that the mode, after stripping 'U', begins with 'r', 'w' or
> 'a'.
>
> pythonÇ¿ÖÆÖ´ÐдËģʽ,ÔÚ'u'֮ǰ,ÔÚ'r','w'or'a'Ö®ºó.
>
> Changed in version 2.5: Restriction on first letter of mode string
> introduced.
>
> 2.5°æ±¾µÄ¸Ä±ä:ÏÞÖƵÚÒ»¸ö×Ö·û·½Ê½´«ÈëµÄ×Ö·û
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061214/44e94640/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 13:34

boyeestudio boyee118在gmail.com
星期四 十二月 14 13:34:29 HKT 2006

>
> Õâ¶Î£¬ÎÒÊÔһϣº
>
> 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.
> >
> > ³ýÁ˱ê×¼fopen()ģʽֵ֮Í⻹¿ÉʹÓÃ'U' »òÕß
> > 'rU'.python¹ßÀý¹¹ÔìÁËͨÓû»ÐÐÖ§³Ö;Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython²»¹¹ÔìÒ»¸öͨÓû»ÐÐÖ§³Öģʽ'u'À´ÓÃͳһ¶Ô´ýÕý³£Îı¾Ä£Ê½µÄ»°...²»»á·­.
> >
>
>
> ³ýÁ˱ê×¼µÄfopen(),ֵģʽ»¹¿ÉΪ'U'»òÕß'rU'.ͨ³££¬PythonÒÑÄÚ½¨Í³Ò»µÄ»»ÐÐÖ§³Ö£¡
> Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpythonûÓÐÄÚ½¨
> Ò»¸öͨÓû»ÐÐÖ§³Ö,ÄÇô'U'ģʽÓëͨÓÃÎļþÄ£ÊÔûʲôÇø±ðÁË¡£×¢Ò⣬Èç´Ë´ò¿ªµÄËùÓÐÎļþ¶ÔÏóÒ²ÓÐÒ»¸ö³ÆΪ»»ÐеÄÊôÐÔ£¬ÆäֵΪNone(Èç¹û¿´²»µ½ÐÂÐоÍÊÇÕâÖÖÇé¿ö),'\n',
> '\r', '\r\n',»òÕßÊÇÒ»¸ö°üº¬ËùÓпɼûµÄ»»ÐÐÀàÐ͵ÄÔª×é¡££¨×¢£ºÕâ¸öֵΪÉÏÃæÎåÖÖÖ®Ò»£©
>
> Çë¸ßÊÖÖ¸½Ì£¡Ð»Ð»£¡
>
²»ºÃÒâ˼£¬´ò´í¸ö×Ö£¬ÊÇÎ壬²»ÊÇËÄ¡£:)
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061214/5fd3379b/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 20:57

Yunfeng Tao taoyfeng在gmail.com
星期四 十二月 14 20:57:25 HKT 2006

有几句译得不够妥贴。我提点小意见。

原文:In addition to the standard fopen() values mode may be 'U' or 'rU'.
译文:除了标准的fopen(),值模式还可为'U'或者'rU'.
这句里的mode,指的是open()的参数mode。我以为不译更佳。译了反而有可能误导读者,使读者以为另有一个"模式"概念,不同于参数mode。而且,句读位置不对。原文的意思,我揣测是这样的:in
addition to the standard fopen() values, mode may be ...
试译:参数mode不仅可取标准fopen()可用的值,也可取'U'或者'rU'。

原文:Python is usually built with universal newline support;
译文:通常,Python已内建统一的换行支持!
"内建"的英文是built-in,这里用来翻译be built with这个被动语态,不妥。build有人翻译成"构建",比如"daily
build"。我也以为不妥,因为"构建"有故意掉书袋的味道。"构建"其实就是"构造",而"构造"又和build之意不合。我认为"编译"较好。其一,"编译"在大陆计算机科学界是习语,如"编译原理"。我同时注意到,编译原理之编译是compilation,不是build。粗略来讲,build=compilation+link。体会原句的意思,我认为这里的build偏重于compilation,而非link。此其二。最后但非最不重要,universal是通用,不是统一。
试译:python通常以支持通用换行符的方式编译。

原文:supplying 'U' opens the file as a text file
译文:提供'U'模式以文本方式打开一个文件
译文计有动词二个,颇难索解主谓宾。原文说得清楚,谓语是open,主语是supplying 'U'这样一个名词性短语,指的是参数mode里有大写字母U这件事情。
试译:参数mode中若有'U',则将以文本方式打开文件。

原文: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'.
译文:但是行可能随时结束:Unix的结束符规定为'\n',苹果系统则为'\r',还有windows规定为'\r\n'
any of the following指的是后面列举的三种行结束符之任意一种,不是"随时"的意思。另外,从匀称的角度看,unix和windows皆不译,独独将macintosh译出来,稍有不妥。convention不是规定,是惯例,但在这里不重要。
试译:1. 然而,行可能以下列方式之一终止:Unix式的'\n',Macintosh式的'\r',或者Windows式的'\r\n'。
更准确的意译应该是:
2. 然而,(文件的)行结束符可能是下列三种之一:Unix式的'\n',Macintosh式的'\r',或者Windows式的'\r\n'。

原文:All of these external representations are seen as '\n' by the Python program.
译文:所有这些规定在python程序中统一为'\n'.
原文的意思是"视作",并非"统一",意在强调内外有别,非"车同轨"。
试译:所有这几种文件里的行结束符,python程序都视作'\n'。

原文:If Python is built without universal newline support a mode with
'U' is the same as normal text mode.
译文:如果python 没有内建一个通用换行支持,那么'U'模式与通用文件模试没什么区别了。
normal和通用,差得比较远。
试译:如果python没有以支持通用换行符的方式编译,那么带'U'的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.
译文:注意,如此打开的所有文件对象也有一个称为换行的属性,其值为None(如果看不到新行就是这种情况),'\n', '\r',
'\r\n',或者是一个包含所有可见的换行类型的元组。(注:这个值为上面五种之一)
最后的seen不是"可见"的意思,而是"被看到",前面的"if no newlines have yet been seen"说得很明确了。
译文:注意:这样打开的文件对象有一个newlines属性,其值为None(如果尚不曾见到任何换行符)、'\n'、'\r'、'\r\n',或一个元组,其中包括所有已经见到的换行符类型。


在 06-12-14,boyeestudio<boyee118在gmail.com> 写道:
> >
> > 这段,我试一下:
> > >
> > > 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.
> > >
> > > 除了标准fopen()模式值之外还可使用'U' 或者
> 'rU'.python惯例构造了通用换行支持;提供'U'模式以文本方式打开一个文件,但是行可能随时结束:Unix的结束符规定为'\n',苹果系统则为'\r',还有windows规定为'\r\n',所有这些规定在python程序中统一为'\n'.如果python不构造一个通用换行支持模式'u'来用统一对待正常文本模式的话...不会翻.
> >
> 除了标准的fopen(),值模式还可为'U'或者'rU'.通常,Python已内建统一的换行支持!提供'U'模式以文本方式打开一个文件,但是行可能随时结束:Unix的结束符规定为'\n',苹果系统则为'\r',还有windows规定为'\r\n',所有这些规定在python程序中统一为'\n'.如果python
> 没有内建一个通用换行支持,那么'U'模式与通用文件模试没什么区别了。注意,如此打开的所有文件对象也有一个称为换行的属性,其值为None(如果看不到新行就是这种情况),'\n',
> '\r', '\r\n',或者是一个包含所有可见的换行类型的元组。(注:这个值为上面五种之一)
> >
> > 请高手指教!谢谢!
> >
> 不好意思,打错个字,是五,不是四。:)
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月14日 星期四 22:14

boyeestudio boyee118在gmail.com
星期四 十二月 14 22:14:43 HKT 2006

2006/12/14, Yunfeng Tao <taoyfeng在gmail.com>:
>
> Óм¸¾äÒëµÃ²»¹»Í×Ìù¡£ÎÒÌáµãСÒâ¼û¡£
>
> Ô­ÎÄ£ºIn addition to the standard fopen() values mode may be 'U' or 'rU'.
> ÒëÎÄ£º³ýÁ˱ê×¼µÄfopen(),ֵģʽ»¹¿ÉΪ'U'»òÕß'rU'.
>
> Õâ¾äÀïµÄmode£¬Ö¸µÄÊÇopen()µÄ²ÎÊýmode¡£ÎÒÒÔΪ²»Òë¸ü¼Ñ¡£ÒëÁË·´¶øÓпÉÄÜÎ󵼶ÁÕߣ¬Ê¹¶ÁÕßÒÔΪÁíÓÐÒ»¸ö"ģʽ"¸ÅÄ²»Í¬ÓÚ²ÎÊýmode¡£¶øÇÒ£¬¾ä¶ÁλÖò»¶Ô¡£Ô­ÎĵÄÒâ˼£¬ÎÒ´§²âÊÇÕâÑùµÄ£ºin
> addition to the standard fopen() values, mode may be ...
> ÊÔÒ룺²ÎÊýmode²»½ö¿ÉÈ¡±ê×¼fopen()¿ÉÓõÄÖµ£¬Ò²¿ÉÈ¡'U'»òÕß'rU'¡£
>
> Ô­ÎÄ£ºPython is usually built with universal newline support;
> ÒëÎÄ£ºÍ¨³££¬PythonÒÑÄÚ½¨Í³Ò»µÄ»»ÐÐÖ§³Ö£¡
> "ÄÚ½¨"µÄÓ¢ÎÄÊÇbuilt-in£¬ÕâÀïÓÃÀ´·­Òëbe built withÕâ¸ö±»¶¯Óï̬£¬²»Íס£buildÓÐÈË·­Òë³É"¹¹½¨"£¬±ÈÈç"daily
>
> build"¡£ÎÒÒ²ÒÔΪ²»Í×£¬ÒòΪ"¹¹½¨"ÓйÊÒâµôÊé´üµÄζµÀ¡£"¹¹½¨"Æäʵ¾ÍÊÇ"¹¹Ôì"£¬¶ø"¹¹Ôì"ÓÖºÍbuildÖ®Òâ²»ºÏ¡£ÎÒÈÏΪ"±àÒë"½ÏºÃ¡£ÆäÒ»£¬"±àÒë"ÔÚ´ó½¼ÆËã»ú¿Æѧ½çÊÇÏ°ÓÈç"±àÒëÔ­Àí"¡£ÎÒͬʱעÒâµ½£¬±àÒëÔ­ÀíÖ®±àÒëÊÇcompilation£¬²»ÊÇbuild¡£´ÖÂÔÀ´½²£¬build=compilation+link¡£Ìå»áÔ­¾äµÄÒâ˼£¬ÎÒÈÏΪÕâÀïµÄbuildÆ«ÖØÓÚcompilation£¬¶ø·Çlink¡£´ËÆä¶þ¡£×îºóµ«·Ç×î²»ÖØÒª£¬universalÊÇͨÓ㬲»ÊÇͳһ¡£
> ÊÔÒ룺pythonͨ³£ÒÔÖ§³ÖͨÓû»ÐзûµÄ·½Ê½±àÒë¡£
>
> Ô­ÎÄ£ºsupplying 'U' opens the file as a text file
> ÒëÎÄ£ºÌṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ
> ÒëÎļÆÓж¯´Ê¶þ¸ö£¬ÆÄÄÑË÷½âÖ÷ν±ö¡£Ô­ÎÄ˵µÃÇå³þ£¬Î½ÓïÊÇopen£¬Ö÷ÓïÊÇsupplying
> 'U'ÕâÑùÒ»¸öÃû´ÊÐÔ¶ÌÓָµÄÊDzÎÊýmodeÀïÓдóд×ÖĸUÕâ¼þÊÂÇé¡£
> ÊÔÒ룺²ÎÊýmodeÖÐÈôÓÐ'U'£¬Ôò½«ÒÔÎı¾·½Ê½´ò¿ªÎļþ¡£
>
> Ô­ÎÄ£º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'.
> ÒëÎÄ£ºµ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n'
> any of the
> followingÖ¸µÄÊǺóÃæÁоٵÄÈýÖÖÐнáÊø·ûÖ®ÈÎÒâÒ»ÖÖ£¬²»ÊÇ"Ëæʱ"µÄÒâ˼¡£ÁíÍ⣬´ÓÔȳƵĽǶȿ´£¬unixºÍwindows½Ô²»Ò룬¶À¶À½«macintoshÒë³öÀ´£¬ÉÔÓв»Íס£convention²»Êǹ涨£¬ÊǹßÀý£¬µ«ÔÚÕâÀï²»ÖØÒª¡£
> ÊÔÒ룺1. È»¶ø£¬ÐпÉÄÜÒÔÏÂÁз½Ê½Ö®Ò»ÖÕÖ¹£ºUnixʽµÄ'\n'£¬MacintoshʽµÄ'\r'£¬»òÕßWindowsʽµÄ'\r\n'¡£
> ¸ü׼ȷµÄÒâÒëÓ¦¸ÃÊÇ£º
> 2. È»¶ø£¬£¨ÎļþµÄ£©ÐнáÊø·û¿ÉÄÜÊÇÏÂÁÐÈýÖÖÖ®Ò»£ºUnixʽµÄ'\n'£¬MacintoshʽµÄ'\r'£¬»òÕßWindowsʽµÄ'\r\n'¡£
>
> Ô­ÎÄ£ºAll of these external representations are seen as '\n' by the Python
> program.
> ÒëÎÄ£ºËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.
> Ô­ÎĵÄÒâ˼ÊÇ"ÊÓ×÷"£¬²¢·Ç"ͳһ"£¬ÒâÔÚÇ¿µ÷ÄÚÍâÓб𣬷Ç"³µÍ¬¹ì"¡£
> ÊÔÒ룺ËùÓÐÕ⼸ÖÖÎļþÀïµÄÐнáÊø·û£¬python³ÌÐò¶¼ÊÓ×÷'\n'¡£
>
> Ô­ÎÄ£ºIf Python is built without universal newline support a mode with
> 'U' is the same as normal text mode.
> ÒëÎÄ£ºÈç¹ûpython ûÓÐÄÚ½¨Ò»¸öͨÓû»ÐÐÖ§³Ö,ÄÇô'U'ģʽÓëͨÓÃÎļþÄ£ÊÔûʲôÇø±ðÁË¡£
> normalºÍͨÓ㬲îµÃ±È½ÏÔ¶¡£
> ÊÔÒ룺Èç¹ûpythonûÓÐÒÔÖ§³ÖͨÓû»ÐзûµÄ·½Ê½±àÒ룬ÄÇô´ø'U'µÄ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.
> ÒëÎÄ£º×¢Ò⣬Èç´Ë´ò¿ªµÄËùÓÐÎļþ¶ÔÏóÒ²ÓÐÒ»¸ö³ÆΪ»»ÐеÄÊôÐÔ£¬ÆäֵΪNone(Èç¹û¿´²»µ½ÐÂÐоÍÊÇÕâÖÖÇé¿ö),'\n', '\r',
> '\r\n',»òÕßÊÇÒ»¸ö°üº¬ËùÓпɼûµÄ»»ÐÐÀàÐ͵ÄÔª×é¡££¨×¢£ºÕâ¸öֵΪÉÏÃæÎåÖÖÖ®Ò»£©
> ×îºóµÄseen²»ÊÇ"¿É¼û"µÄÒâ˼£¬¶øÊÇ"±»¿´µ½"£¬Ç°ÃæµÄ"if no newlines have yet been seen"˵µÃºÜÃ÷È·ÁË¡£
>
> ÒëÎÄ£º×¢Ò⣺ÕâÑù´ò¿ªµÄÎļþ¶ÔÏóÓÐÒ»¸önewlinesÊôÐÔ£¬ÆäֵΪNone£¨Èç¹ûÉв»Ôø¼ûµ½Èκλ»Ðзû£©¡¢'\n'¡¢'\r'¡¢'\r\n'£¬»òÒ»¸öÔª×飬ÆäÖаüÀ¨ËùÓÐÒѾ­¼ûµ½µÄ»»ÐзûÀàÐÍ¡£


´ó¸ç²»´í£¬×ÖÕå¾ä×ã¬Ð¡µÜÅå·þ£¡ÏòÄãѧϰ£¡£¡

ÔÚ 06-12-14£¬boyeestudio<boyee118在gmail.com> дµÀ£º
> > >
> > > Õâ¶Î£¬ÎÒÊÔһϣº
> > > >
> > > > 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.
> > > >
> > > > ³ýÁ˱ê×¼fopen()ģʽֵ֮Í⻹¿ÉʹÓÃ'U' »òÕß
> >
> 'rU'.python¹ßÀý¹¹ÔìÁËͨÓû»ÐÐÖ§³Ö;Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython²»¹¹ÔìÒ»¸öͨÓû»ÐÐÖ§³Öģʽ'u'À´ÓÃͳһ¶Ô´ýÕý³£Îı¾Ä£Ê½µÄ»°...²»»á·­.
> > >
> >
> ³ýÁ˱ê×¼µÄfopen(),ֵģʽ»¹¿ÉΪ'U'»òÕß'rU'.ͨ³££¬PythonÒÑÄÚ½¨Í³Ò»µÄ»»ÐÐÖ§³Ö£¡Ìṩ'U'ģʽÒÔÎı¾·½Ê½´ò¿ªÒ»¸öÎļþ,µ«ÊÇÐпÉÄÜËæʱ½áÊø:UnixµÄ½áÊø·û¹æ¶¨Îª'\n',Æ»¹ûϵͳÔòΪ'\r',»¹ÓÐwindows¹æ¶¨Îª'\r\n',ËùÓÐÕâЩ¹æ¶¨ÔÚpython³ÌÐòÖÐͳһΪ'\n'.Èç¹ûpython
> >
> ûÓÐÄÚ½¨Ò»¸öͨÓû»ÐÐÖ§³Ö,ÄÇô'U'ģʽÓëͨÓÃÎļþÄ£ÊÔûʲôÇø±ðÁË¡£×¢Ò⣬Èç´Ë´ò¿ªµÄËùÓÐÎļþ¶ÔÏóÒ²ÓÐÒ»¸ö³ÆΪ»»ÐеÄÊôÐÔ£¬ÆäֵΪNone(Èç¹û¿´²»µ½ÐÂÐоÍÊÇÕâÖÖÇé¿ö),'\n',
> > '\r', '\r\n',»òÕßÊÇÒ»¸ö°üº¬ËùÓпɼûµÄ»»ÐÐÀàÐ͵ÄÔª×é¡££¨×¢£ºÕâ¸öֵΪÉÏÃæÎåÖÖÖ®Ò»£©
> > >
> > > Çë¸ßÊÖÖ¸½Ì£¡Ð»Ð»£¡
> > >
> > ²»ºÃÒâ˼£¬´ò´í¸ö×Ö£¬ÊÇÎ壬²»ÊÇËÄ¡£:)
> >
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061214/747469f7/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年12月19日 星期二 23:17

张羽翱翔 zyaxcn在gmail.com
星期二 十二月 19 23:17:09 HKT 2006

收藏!

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号