用Python寫ASP

來源:互聯網
上載者:User

python可以用來寫asp,沒聽說過吧,老實說,我也是今天無意間才知道,於是也自己嘗試了一下。下載了ActivePython,裝上後,測試了一下代碼,順利通過!

 
  1. <% @language="python" codepage="936" %>  
  2. <%  
  3. # demo1-輸出中文  
  4. class demo:  
  5.   def say(self):  
  6.     return u"你好我的朋友" 
  7. d=demo()  
  8. Response.Write(d.say())  
  9.  
  10. # demo2-使用正則  
  11. Response.Write("<BR>")  
  12. import re  
  13. p=re.compile(",")  
  14. a=p.split("a,b,c")  
  15. for x in a:  
  16.   Response.Write("value:" + x + "<BR>")  
  17.  
  18. p2=re.compile("item\d+")  
  19. a2=p2.findall("1 list item1 2 list item2 3 list item3")  
  20. for x in a2:  
  21.   Response.Write("value:" + x + "<BR>")  
  22. %> 

特別需要注意的是編碼,否則不能輸出中文,這裡我寫了這兩個簡易的例子,一個是類執行個體的輸出,一個是正則的使用,更詳細的使用還在探索中...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.