脚本专栏 
首页 > 脚本专栏 > 浏览文章

python中upper是做什么用的

(编辑:jimmy 日期: 2025/2/27 浏览:3 次 )

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实现生成指定大小txt文档
下一篇:python怎么删除缓存文件
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。