Discuss / Python / capitalize 及 upper 等的用法,有没有parameter

capitalize 及 upper 等的用法,有没有parameter

Topic source

str1 = 'are you Kidding meE' 1: print (str1.capitalize()) print (str1.upper()) 2: print (str.capitalize(str1)) print (str.upper(str1))

应该是没有parameter的。但是2:这种调用也出正确结果是怎么回事

灰_手

#2 Created at ... [Delete] [Delete and Lock User]

这里涉及比较底层的东西,如果你学过其他编程语言的话,应该会听说过函数指针这种东西

class Foo(object):
    def func(self):
        print(repr(self))

f = Foo()

# 你可以发现这两个打印结果都是一样的
f.func()
Foo.func(f)

  • 1

Reply