python的内置函数
来源:互联网 发布:路由器劫持软件 编辑:程序博客网 时间:2024/05/02 17:34
__str__是返回对象的字符窜表达式
fromdjango.dbimport modelsclassReporter(models.Model):
full_name= models.CharField(max_length=70)
def__str__(self):# __unicode__ on Python 2
returnself.full_name
classArticle(models.Model):
pub_date= models.DateField()
headline= models.CharField(max_length=200)
content= models.TextField()
reporter= models.ForeignKey(Reporter, on_delete=models.CASCADE)
def__str__(self):# __unicode__ on Python 2
returnself.headline
这个是Django的代码,当我们获得Reporter这个对象的实例的时候,re = Reporter(full_name='test'), 得到的是self.full_name的字符串表达式
0 0
- python的内置函数
- python的内置函数
- python的内置函数
- python的内置函数
- python的内置函数简介
- python的一些内置函数
- python的OS内置函数
- Python所有的内置函数
- python 常用的内置函数
- Python模块的内置函数
- Python-常用的内置函数
- Python常用的内置函数
- 【python】python的几个内置函数
- python 常用的Python内置函数
- Python的内置函数和匿名函数
- python函数: 内置函数
- Python中class的内置函数__str__
- Python内置的字符串处理函数整理
- Java内部类的使用小结
- GPU架构
- Android/linux 平台下使用 i2c-tools调试IIC方法
- 通过调用门进行控制转移 ——《x86汇编语言:从实模式到保护模式》读书笔记29
- 07:和为给定数OJ
- python的内置函数
- C++作业5
- 学习PS基础教程
- python numpy模块玩转矩阵与科学计算
- Codeforces--525B--Pasha and String(思维)
- OpenCL buffer使用及两个简单例子
- js与android代码的交互
- [SCU 4500] 神舟的宝藏 (数位DP)
- yii2缓存的介绍和使用