首頁 >後端開發 >Python教學 >Python写的英文字符大小写转换代码示例

Python写的英文字符大小写转换代码示例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-06 11:21:491715瀏覽

几行代码的小工具,用于进行如下转换

TRANSACTIONS ON CLOUD COMPUTING

=》

Transactions On Cloud Computing

代码如下:


orig = 'TRANSACTIONS ON CLOUD COMPUTING'
splited = orig.split(' ')
handled = ''
for word in splited:
    word = word[0] +  word[1:].lower()
    handled += (' ' + word)
handled = handled[1:]
print handled
#handled is 'Transactions On Cloud Computing'

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn