当前位置: 首页>>代码示例>>Python>>正文


Python FileIO.name方法代码示例

本文整理汇总了Python中io.FileIO.name方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.name方法的具体用法?Python FileIO.name怎么用?Python FileIO.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.FileIO的用法示例。


在下文中一共展示了FileIO.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wrapper

# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import name [as 别名]
 def wrapper(self, file_, *args, **kwargs):
     if isinstance(file_, basestring):
         # Using FileIO here instead of open()
         # to be able to override the filename
         # which is later used when uploading the file.
         #
         # Explanation:
         #
         # 1) Restkit reads the filename
         # from "name" attribute of a file-like object,
         # there is no other way to specify a filename;
         #
         # 2) The attribute may contain the full path to file,
         # which does not work well as a filename;
         #
         # 3) The attribute is readonly when using open(),
         # unlike FileIO object.
         file_ = FileIO(file_, 'rb')
         file_.name = path.basename(file_.name)
     if hasattr(file_, 'read'):
         # A file-like object must have 'read' method
         return fn(self, file_, *args, **kwargs)
     else:
         raise TypeError('Expected either a string '
                         'containing a path to file or a '
                         'file-like object, got {}'.format(type(file_)))
开发者ID:kosaniak,项目名称:openprocurement.client.python,代码行数:28,代码来源:client.py


注:本文中的io.FileIO.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。