Python3与Python2中print的用法改变与Class获取属性学习
来源:互联网 发布:淘宝登录界面无法打开 编辑:程序博客网 时间:2024/06/08 14:19
Reference: http://planet.python.org/
python2中 print 'hello world'
python3中 print ('hello world')
获取属性的方法使用__dict__
import inspectclass Test: """""" #-------------------------------------------- def __init__(self): self.varOne = "" self.varTwo = "" self.varThree = "" #-------------------------------------------- def methodOne(self): """""" # print "You just called methodOne!" print ("You just called methodOne!")#----------------------------------------------------if __name__ == "__main__": t = Test() variables = [i for i in t.__dict__ if not inspect.ismethod(i)] print (variables) print ('End of File')以下两种方法也可以,并且第二种不需要import inspect.
variables = [i for i in t.__dict__ if not callable(i)]
variables = t.__dict__.keys()
- Python3与Python2中print的用法改变与Class获取属性学习
- python2.7与python3中print的一点不同之处
- Python2与Python3的区别(三):print
- python2 与python3的print差异
- python2.x 与 python3.x 中print函数
- 注意Python2.x与Python3.x中的print与print()用法(invalid syntax错误)
- python2与python3的print及字符串格式化总结
- Python3中的print函数以及与python2的比较
- python3和python2中print的用法有很多不同,python3中需要使用括号
- python3与python2中字符串的区别
- Python2和Python3的print
- python2的print和python3的print()
- Python2与Python3的区别
- python2与python3的区别
- python2与python3的区别
- Python3与Python2的区别
- python2与python3的区别
- Python2与Python3的区别
- soj 2302. Queue Implementation Using a Circular Array
- 设计模式之工厂方法模式
- XShell 技巧分享
- iframe的父类 子类相互调用
- VMware虚拟机上网络连接(network type)的三种模式--bridged、host-only、NAT
- Python3与Python2中print的用法改变与Class获取属性学习
- monster campaign
- 设计模式之抽象工厂模式
- poj 1192 最优连通子集
- PHP好用的上传类
- python使用文件对话框
- 设计模式之单件模式
- 如何写出高质量的JavaScript代码
- Android HAL实例解析 .