本文整理汇总了Python中io.FileIO.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.__init__方法的具体用法?Python FileIO.__init__怎么用?Python FileIO.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.FileIO
的用法示例。
在下文中一共展示了FileIO.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import __init__ [as 别名]
def __init__(self, name, mode="rb", buffering=0):
"""file(name[, mode[, buffering]]) -> file object
Open a file. The mode can be 'r', 'w' or 'a' for reading (default),
writing or appending. The file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing. Add a 'b' to the mode for binary files.
Add a '+' to the mode to allow simultaneous reading and writing.
If the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size. The preferred way
to open a file is with the builtin open() function.
Add a 'U' to mode to open the file for input with universal newline
support. Any line ending in the input file will be seen as a '\n'
in Python. Also, a file so opened gains the attribute 'newlines';
the value for this attribute is one of None (no newline read yet),
'\r', '\n', '\r\n' or a tuple containing all the newline types seen.
'U' cannot be combined with 'w' or '+' mode.
"""
if six.PY2:
FileIO.__init__(self, name, mode, buffering)
else: # for python3 we drop buffering
FileIO.__init__(self, name, mode)
self.lock = _Semaphore()
self.__size = None
示例2: __init__
# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import __init__ [as 别名]
def __init__(self, filename, nstates=-1, natoms=-1, vendor="PyMOL", box=None):
file.__init__(self, filename, "w")
self.natoms = natoms
self.box = box
# Write Trajectory Header Information
print("TITLE : Created by %s with %d atoms" % (vendor, natoms), file=self)
示例3: __init__
# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import __init__ [as 别名]
def __init__(self, fname, endian='@', header_prec='i', *args, **kwargs):
"""Open a Fortran unformatted file for writing.
Parameters
----------
endian : character, optional
Specify the endian-ness of the file. Possible values are
'>', '<', '@' and '='. See the documentation of Python's
struct module for their meanings. The deafult is '>' (native
byte order)
header_prec : character, optional
Specify the precision used for the record headers. Possible
values are 'h', 'i', 'l' and 'q' with their meanings from
Python's struct module. The default is 'i' (the system's
default integer).
"""
file.__init__(self, fname, *args, **kwargs)
self.ENDIAN = endian
self.HEADER_PREC = header_prec
示例4: __init__
# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import __init__ [as 别名]
def __init__(self, prog, *args, **kwargs):
FileIO.__init__(self, *args, **kwargs)
self.prog = prog