Home > Backend Development > Python Tutorial > 用python实现面向对像的ASP程序实例

用python实现面向对像的ASP程序实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 11:20:25
Original
1101 people have browsed it

本文实例讲述了用python实现面向对像的ASP程序的方法。分享给大家供大家参考。具体实现方法如下:

平时我们写ASP时,一般都用vbscript或javascript.
javascript是用function来实现类的,很麻烦,而且效果不爽. vbscript虽然可以实现类,但是功能上也有很大的局限性.
如果用python来写ASP脚本,就可以实现真的类,成为真正的面向对像.请看下面的例子:

代码如下:


import sys
import urllib
class urtt:
def __init__(self):
self.text1='testpython'
def urt(self):
fr=urllib.urlopen('http://www.bitsCN.com')
for fl in fr.readlines():
Response.Write(Server.HTMLEncode(fl))
fr.close()
Response.Write(self.text1)
class urtta(urtt):
def __init__(self,url):
self.strurl=url
self.text1='textpython'
def urts(self):
fr=urllib.urlopen(self.strurl)
for fl in fr.readlines():
Response.Write(Server.HTMLEncode(fl))
fr.close()
Response.Write(self.text1)
utta=urtt()
utta.urt()
utt=urtta("http://sohu.com")
utt.urts()
%>

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template