python是干什么用的-python中upper是做什么用的

Python upper()方法

Python 字符串

描述

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 wait!")

class E(B,C):

pass

a = A()

b = B()

c = C()

d = D()

e = E()

# 说明下列代码的输出结果

a.go()

print('--------')

b.go()

print('--------')

c.go()

print('--------')

d.go()

print('--------')

e.go()

print('--------')

a.stop()

print('--------')

b.stop()

print('--------')

c.stop()

print('--------')

d.stop()

print('--------')

e.stop()

print(D.mro())

a.pause()

b.pause()

c.pause()

d.pause()

e.pause()

到此这篇关于python中upper是做什么用的的文章就介绍到这了,更多相关python中upper的作用内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值