欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

python中upper是做什么用的

时间:2021-03-10 09:27:44|栏目:Python代码|点击:

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数据分析:关键字提取方式

栏    目:Python代码

下一篇:Python全排列操作实例分析

本文标题:python中upper是做什么用的

本文地址:http://www.codeinn.net/misctech/78229.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有