美文网首页
oldnewstyle

oldnewstyle

作者: 愿你有闯荡风雪的骁勇 | 来源:发表于2018-10-31 17:56 被阅读0次

    先来两个小常识
    import sys

    print(sys.version)

    a='let\'s go!go'

    print(a)

    C:\Users\sunqicheng\PycharmProjects\object\venv\Scripts\python.exe C:/Users/sunqicheng/PycharmProjects/object/sysversion.py

    3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]

    let's go!go

    -------------------------------------------------------------------------------------------------------------

    class Oldstyle:

        def __init__(self,name,description):

            self.name=name

            self.description=description

    class Newstyle(object):

        def __init__(self,name,description):

            self.name=name

            self.description=description

    if __name__=='__main__':

        old=Oldstyle('孙启成','健身')

        print(old)##<__main__.Oldstyle object at 0x00000206D3342710>对象的main方法,是这个类在某个地方拉的一个小屎

        print(type(old))#输出对象的main方法<class '__main__'.Oldstyle'>

        print(dir(old))#这个old对象有这么多内置的方法

        new=Newstyle('齐东兴','型男')

        new2=Newstyle('东兴','型男')

        print(new2)

        print(new)#<__main__.Newstyle object at 0x000002CO5ABF85CO>对象的main方法,是这个类在这个地方拉的一个小屎

        print(type(new))

        print(dir(new))

    --------------------------------------------------------------

    C:\Users\sunqicheng\PycharmProjects\object\venv\Scripts\python.exe C:/Users/sunqicheng/PycharmProjects/object/oldnewstyle.py

    <__main__.Oldstyle object at 0x00000212B87E2828>

    <class '__main__.Oldstyle'>

    ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'description', 'name']

    <__main__.Newstyle object at 0x00000212B87E8390>

    <__main__.Newstyle object at 0x00000212B87E85C0>

    <class '__main__.Newstyle'>

    ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'description', 'name']

    Process finished with exit code 0

    相关文章

      网友评论

          本文标题:oldnewstyle

          本文链接:https://www.haomeiwen.com/subject/aezatqtx.html