python中upper是做什么用的
更新時間:2020年07月20日 08:31:39 作者:曉曦&sea
在本篇文章里小編給大家整理的是一篇關于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的作用內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
python中的os.mkdir和os.makedirs的使用區(qū)別及如何查看某個模塊中的某些字母開頭的屬性方法
這篇文章主要介紹了python中的os.mkdir和os.makedirs的使用區(qū)別及如何查看某個模塊中的某些字母開頭的屬性方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03
在Python中畫圖(基于Jupyter notebook的魔法函數)
這篇文章主要介紹了在Python中畫圖(基于Jupyter notebook的魔法函數),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2019-10-10
使用Python實現(xiàn)簡單的人臉識別功能(附源碼)
Python中實現(xiàn)人臉識別功能有多種方法,依賴于python膠水語言的特性,我們通過調用包可以快速準確的達成這一目的,本文給大家分享使用Python實現(xiàn)簡單的人臉識別功能的操作步驟,感興趣的朋友一起看看吧2021-12-12

