Python 函数
来源:互联网 发布:highcharts zh ch.js 编辑:程序博客网 时间:2024/05/23 23:58
1. ",".join()
>>> ",".join(["a", "b", "c"])
'a,b,c'
The "," is inserted between each element of the given list. In your case, your "list" is the string representation "595", which is treated as the list ["5", "9", "5"].
2. SringIO
7.5. StringIO — Read and write strings as files
This module implements a file-like class, StringIO, that reads and writes a string buffer (also known as memory files). See the description of file objects for operations (section File Objects). (For standard strings, see str and unicode.)
- class StringIO.StringIO([buffer])
When a StringIO object is created, it can be initialized to an existing string by passing the string to the constructor. If no string is given, the StringIOwill start empty. In both cases, the initial file position starts at zero.
The StringIO object can accept either Unicode or 8-bit strings, but mixing the two may take some care. If both are used, 8-bit strings that cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause a UnicodeError to be raised when getvalue() is called.
The following methods of StringIO objects require special mention:
- StringIO.getvalue()
Retrieve the entire contents of the “file” at any time before the StringIO object’s close() method is called. See the note above for information about mixing Unicode and 8-bit strings; such mixing can cause this method to raise UnicodeError.
- StringIO.close()
Free the memory buffer. Attempting to do further operations with a closed StringIO object will raise a ValueError.
Example usage:
3. 类的有关概念
---从模块中引用命名是引用属性:表达式 modname.funcname中,modname 是一个模块对象,funcname 是它的一个属性。
----
class MyClass: """A simple example class""" i = 12345 def f(self): return 'hello world'
那么 MyClass.i 和 MyClass.f 是有效的属性引用,分别返回一个整数和一个方法对象。
---另一种为实例对象所接受的引用属性是 方法 。方法是“属于”一个对象的函数。x.f 是一个有效的方法引用,因为 MyClass.f 是一个函数。不过 x.f 和 MyClass.f 不同,它是一个 方法对象,不是一个函数对象。
如果这个命名确认为一个有效的函数对象类属性,就会将实例(类定义)对象和函数对象封装进一个抽象对象:这就是方法对象。
- python函数
- python 函数
- python 函数
- Python 函数
- python 函数
- PYTHON函数
- python 函数
- Python函数
- python 函数
- Python 函数
- Python 函数
- Python 函数
- python函数
- python函数
- python 函数
- Python 函数
- Python函数
- Python函数
- http://blog.csdn.net/wsh900221/article/details/23285283
- 【Sublime】Sublime Text 插件添加/移除方法
- 联名账户
- iOS开发之深入探讨runtime机制01-类与对象
- 项目中知识点的总结
- Python 函数
- 最新随笔 最新评论 Class.forName的作用以及为什么要用它
- Freemarker详解
- Spring读取properties文件出现乱码的解决方法
- windows端口查询与状态详解
- hdu 5171(矩阵快速幂)
- Android客户端与PC服务器通过socket进行交互实例
- 获取Android设备的方向 -- gsensor
- iOS开发之深入探讨runtime机制02-runtime的简单使用