Python upper() 方法将字符串中的小写字母转为大写字母。

语法

upper()方法语法:

str.upper()

参数

NA。

返回值

返回小写字母转为大写字母的字符串。

实例

以下实例展示了 upper()函数的使用方法:

#!/usr/bin/python

str = "this is string example....wow!!!"

print "str.upper() : ", str.upper()

以上实例输出结果如下:

str.upper() : THIS IS STRING EXAMPLE....WOW!!!

实例扩展:

class A():

def go(self):

print ("go A go!")

def stop(self):

print ("stop A stop!")

def pause(self):

raise Exception("Not Implemented")

class B(A):

def go(self):

super(B, self).go()

print ("go B go!")

class C(A):

def go(self):

super(C, self).go()

print ("go C go!")

def stop(self):

super(C, self).stop()

print ("stop C stop!")

class D(B,C):

def go(self):

super(D, self).go()

print ("go D go!")

def stop(self):

super(D, self).stop()

print ("stop D stop!")

def pause(self):

print ("wait D