日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python字符串大小寫如何轉(zhuǎn)換

平常開發(fā)過程中對字符串的一些操作:

株洲網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,株洲網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為株洲超過千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個(gè)售后服務(wù)好的株洲做網(wǎng)站的公司定做!

#字母大小寫轉(zhuǎn)換
#首字母轉(zhuǎn)大寫
#去除字符串中特殊字符(如:'_','.',',',';'),然后再把去除后的字符串連接起來
#去除'hello_for_our_world'中的'_',并且把從第一個(gè)'_'以后的單詞首字母大寫

代碼實(shí)例:

#字母大小寫轉(zhuǎn)換
#首字母轉(zhuǎn)大寫
#去除字符串中特殊字符(如:'_','.',',',';'),然后再把去除后的字符串連接起來
#去除'hello_for_our_world'中的'_',并且把從第一個(gè)'_'以后的單詞首字母大寫
low_strs= 'abcd'
uper_strs= 'DEFG'
test_strA= 'hello_world'
test_strB= 'goodBoy'
test_strC= 'hello_for_our_world'
test_strD= 'hello__our_world_'
  
#小寫轉(zhuǎn)大寫
low_strs= low_strs.upper()
print('abcd小寫轉(zhuǎn)大寫:', low_strs)
  
#大寫轉(zhuǎn)小寫
uper_strs= uper_strs.lower()
print('DEFG大寫轉(zhuǎn)小寫:', uper_strs)
  
#只大寫第一個(gè)字母
test_strB= test_strB[0].upper()+ test_strB[1:]
print('goodBoy只大寫第一個(gè)字母:', test_strB)
  
#去掉中間的'_',其他符號都是可以的,如:'.',',',';'
test_strA= ''.join(test_strA.split('_'))
print('hello_world去掉中間的\'_\':', test_strA)
  
#去除'hello_for_our_world'中的'_',并且把從第一個(gè)'_'以后的單詞首字母大寫
def get_str(oriStr,splitStr):
    str_list= oriStr.split(splitStr)
    if len(str_list) >1:
        for indexin range(1,len(str_list)):
            if str_list[index] != '':
                str_list[index]= str_list[index][0].upper()+ str_list[index][1:]
            else:
                continue
        return ''.join(str_list)
    else:
        return oriStr
  
print('去除\'hello_for_our_world\'中的\'_\',并且把從第一個(gè)\'_\'以后的單詞首字母大寫:', get_str(test_strC,'_'))
print('去除\'hello__our_world_\'中的\'_\',并且把從第一個(gè)\'_\'以后的單詞首字母大寫:', get_str(test_strD,'_'))

推薦:Python視頻教程。


本文標(biāo)題:創(chuàng)新互聯(lián)Python教程:python字符串大小寫如何轉(zhuǎn)換
文章出自:http://m.5511xx.com/article/ccdiddh.html