当前位置: 网站首页>小程序开发>网络推广

漳浦设计网页公司

发表日期: 2022-07-04 13:33:14 浏览次数:39

漳浦设计网页公司


网站建设.png

1、资料的录入及修改

2、网站数据库的定期备份

3、网页静态文字的修改

4、网页静态图片的修改

5、产品图片处理

6、由于添加不合理内容而导致网页变形的修正

7、flash动画的修改

8、网站漏洞修补,网站定期杀毒

9、css样式的修改

10、js特效的添加和修改


  1. 反向运算符重载:

    复合重载运算符:

    运算符重载的时候:

    #!/usr/bin/python3class Vector:    def __init__(self, a, b):        self.a = a
            self.b = b
        def __str__(self):        return 'Vector (%d, %d)' % (self.a, self.b)    def __repr__(self):        return 'Vector (%d, %d)' % (self.a, self.b)    def __add__(self,other):        if other.__class__ is Vector:            return Vector(self.a + other.a, self.b + other.b)        elif other.__class__ is int:            return Vector(self.a+other,self.b)    def __radd__(self,other):        """反向算术运算符的重载
            __add__运算符重载可以保证V+int的情况下不会报错,但是反过来int+V就会报错,通过反向运算符重载可以解决此问题
            """        if other.__class__ is int or other.__class__ is float:            return Vector(self.a+other,self.b)        else:            raise ValueError("值错误")    def __iadd__(self,other):        """复合赋值算数运算符的重载
            主要用于列表,例如L1+=L2,默认情况下调用__add__,会生成一个新的列表,
            当数据过大的时候会影响效率,而此函数可以重载+=,使L2直接增加到L1后面
            """        if other.__class__ is Vector:            return Vector(self.a + other.a, self.b + other.b)        elif other.__class__ is int:            return Vector(self.a+other,self.b)v1 = Vector(2,10)v2 = Vector(5,-2)print (v1 + v2)print (v1+5)print (6+v2)
    chise

       chise

      531***371@qq.com

    4年前 (2018-08-30)
    • __iadd__: 加运算

    • __isub__: 减运算

    • __imul__: 乘运算

    • __idiv__: 除运算

    • __imod__: 求余运算

    • __ipow__: 乘方

    • __radd__: 加运算

    • __rsub__: 减运算

    • __rmul__: 乘运算

    • __rdiv__: 除运算

    • __rmod__: 求余运算

    • __rpow__: 乘方

  2.    FS

      429***f0967@qq.com

    442

    FS

       FS

      429***f0967@qq.com

    4年前 (2018-11-22)
  3.    像是一个菜鸟

      141***0013@qq.com

    101

    关于 __name__

    首先需要了解 __name__ 是属于 python 中的内置类属性,就是它会天生就存在于一个 python 程序中,代表对应程序名称。

    比如所示的一段代码里面(这个脚本命名为 pcRequests.py),我只设了一个函数,但是并没有地方运行它,所以当 run 了这一段代码之后我们有会发现这个函数并没有被调用。但是当我们在运行这个代码时这个代码的 __name__ 的值为 __main__ (一段程序作为主线运行程序时其内置名称就是 __main__)。

    import requestsclass requests(object):
        def __init__(self,url):
            self.url=url        self.result=self.getHTMLText(self.url)
        def getHTMLText(url):
            try:
                r=requests.get(url,timeout=30)
                r.raise_for_status()
                r.encoding=r.apparent_encoding            return r.text        except:
                return "This is a error."print(__name__)

    结果:

    __main__Process finished with exit code 0

    当这个 pcRequests.py 作为模块被调用时,则它的 __name__ 就是它自己的名字:

    import pcRequestspcRequestsc=pcRequestsc.__name__

    结果:

    'pcRequests'

    看到这里应该能明白,自己的 __name__ 在自己用时就是 main,当自己作为模块被调用时就是自己的名字,就相当于:我管自己叫我自己,但是在朋友眼里我就是小仙女一样

    像是一个菜鸟

       像是一个菜鸟

      141***0013@qq.com

    3年前 (2019-01-24)
  4.    laoshi

      lao***@ee.com

    35

    Python3 类方法总结

    class People:
    
        # 定义基本属性
        name=''
        age=0
        # 定义私有属性外部无法直接访问
        __weight=0
        def __init__(self,n,a,w):
            self.name = n        self.age = a        self.__weight = w    def speak(self):
            print("%s say : i am %d."%(self.name,self.age))p = People('Python',10,20)p.speak()# __weight无法直接访问print(p.name,'--',p.age)#,'--',p.__weight)

    继承

    单继承:

    class Student(People):
        grade=''
        def __init__(self,n,a,w,g):
            People.__init__(self,n,a,w)
            self.grade = g    # 覆写父类方法
        def speak():
            print("%s 说: 我 %d 岁了,我在读 %d 年级"%(self.name,self.age,self.grade))class Speak():
        topic=''
        name=''
        def __init__(self,n,t):
            self.name = n        self.topic = t    # 普通方法,对象调用
        def speak(self):
            print("我叫 %s,我是一个演说家,我演讲的主题是 %s"%(self.name,self.topic))
    
        # 私有方法,self调用
        def __song(self):
            print('唱一首歌自己听',self);
    
        # 静态方法,对象和类调用,不能和其他方法重名,不然会相互覆盖,后面定义的会覆盖前面的
        @staticmethod
        def song():
            print('唱一首歌给类听:静态方法');
    
        # 普通方法,对象调用
        def song(self):
            print('唱一首歌给你们听',self);
            
        # 类方法,对象和类调用,不能和其他方法重名,不然会相互覆盖,后面定义的会覆盖前面的
        @classmethod
        def song(self):
            print('唱一首歌给类听:类方法',self)

    多继承:

    class Sample(Speak,Student):
        a = ''
        def __init__(self,n,a,w,g,t):
            Student.__init__(self,n,a,w,g)
            Speak.__init__(self,n,t)test = Sample('Song',24,56,7,'Python')test.speak()test.song()Sample.song()Sample.song()test.song()# test.__song() 无法访问私有方法
    laoshi

       laoshi

      lao***@ee.com

    3年前 (2019-05-13)
    •  普通方法:对象访问

    •  私有方法:两个下划线开头,只能在类内部访问

    •  静态方法:类和对象访问,不能和其他方法重名,不然会相互覆盖,后面定义的会覆盖前面的

    •  类方法:类和对象访问,不能和其他方法重名,不然会相互覆盖,后面定义的会覆盖前面的

    •  多继承情况下:从左到右查找方法,找到为止,不然就抛出异常

  5.    徙徒

      143***2467@qq.com

    26

    所有专有方法中,__init__()要求无返回值,或者返回 None。而其他方法,如__str__()、__add__()等,一般都是要返回值的,如下所示:

    >>> class Complex:...     def __init__(self, realpart, imagpart):...         self.r = realpart...         self.i = imagpart...         return 'hello'...>>> x = Complex(3.0, -4.5)Traceback (most recent call last):
      File "<stdin>", line 1, in <module>TypeError: __init__() should return None, not 'str'

    而对于 __str__()、__add__() 等。

    def __str__(self):
            return 'Vector (%d, %d)' % (self.a, self.b)def __repr__(self):
        return 'Vector (%d, %d)' % (self.a, self.b)def __add__(self,other):
        if other.__class__ is Vector:
            return Vector(self.a + other.a, self.b + other.b)
        elif other.__class__ is int:
            return Vector(self.a+other,self.b)
    徙徒

       徙徒

      143***2467@qq.com

    3年前 (2019-06-20)



漳浦设计网页公司

400-111-6878
服务热线
顶部

备案号: 苏ICP备11067224号

CopyRight © 2011 书生商友信息科技 All Right Reserved

24小时服务热线:400-111-6878   E-MAIL:1120768800@qq.com   QQ:1120768800

  网址: https://www.768800.com  网站建设上往建站

关键词: 网站建设| 域名邮箱| 服务器空间| 网站推广| 上往建站| 网站制作| 网站设计| 域名注册| 网络营销| 网站维护|

企业邮箱| 虚拟主机| 网络建站| 网站服务| 网页设计| 网店美工设计| 网站定制| 企业建站| 网站设计制作| 网页制作公司|

400电话办理| 书生商友软件| 葬花网| 调温纤维| 海洋馆运营维护| 北京保安公司| 殡仪馆服务| 殡葬服务| 昌平殡葬| 朝阳殡葬|

预约专家

欢迎您免费咨询,请填写以下信息,我们收到后会尽快与您联系

  

服务热线:400-111-6878