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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python字符串顯示實際應(yīng)用技巧分享

Python編程語言的應(yīng)用,對于開發(fā)人員來說是一個比較好掌握的計算機程序語言。在實際應(yīng)用中,字符串的應(yīng)用是一個比較基礎(chǔ)的操作技術(shù)。我們今天就為大家詳細(xì)介紹一下有關(guān)Python字符串顯示的相關(guān)操作。

創(chuàng)新互聯(lián)公司主要從事網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)克什克騰,十余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

可能是我還沒找到更好的方法,但是小遺憾的是,Python似乎目前無法支持類似shell腳本,perl所支持的標(biāo)量內(nèi)插,所以在顯示的時候無法像下面,這種個人感覺,最清晰,方便的方法。
比如,用戶輸人2個變量‘basketball', 'swimming', shell或者per可以如下顯示出 I love basketball and swimming the best.

 
 
 
  1. #shell
  2. input = 'basketball'
  3. input2 = 'swimming'
  4. print 'I love $input and $input2 the best'
  5. #perl
  6. $input = 'basketball'
  7. $input2 = 'swimming'
  8. print 'I love $input and $input2 the best'

Python字符串顯示如何實現(xiàn)呢,有如下方法,按需選擇吧,希望以后能直接支持類似sell腳本的顯示方法,把$看作轉(zhuǎn)義符:)

 
 
 
  1. import sys
  2. input = sys.argv[1]
  3. input2 = sys.argv[2]
  4. s = 'I love ' + input + ' and ' + input2 + ' the best'
  5. print(s)
  6. s = 'I love %s and %s the best'%(input, input2)
  7. print(s)
  8. params= {'input': input, 'input2': input2 }
  9. s = 'I love %(input)s and %(input2)s the best'%params
  10. 13 print(s)
  11. from string import Template
  12. s = Template('I love $input and $input2 the best')
  13. ss =s.substitute(inputinput=input, input2input2=input2)
  14. print(s)

以上就是我們?yōu)榇蠹医榻B的有關(guān)Python字符串顯示的相關(guān)內(nèi)容。


當(dāng)前題目:Python字符串顯示實際應(yīng)用技巧分享
文章路徑:http://www.5511xx.com/article/ccicjpe.html