比如:CodehighlightingproducedbyActiproCodeHighlighter(freeware)http://www.CodeHighlighter.com/-->import linecacheprint linecache.getline('2.1_open.py', 4)将返回我上一节事例代码文件2.1_open.py的第4行文字,输出结果:f=open('/home/evergreen/桌面/test')查看linecache中的实现(我用的是Ulipad,所以直接将光标停留在linecache处,按F6键)...
http://www.jb51.net//article/15710.htm
[code]mulLine="""Hello!!!WellcometoPython'sworld!Therearealotofinterestingthings!Enjoyyourself.Thankyou!"""print''.join(mulLine.splitlines())print'------------'print''.join(mulLine.splitlines(True))[/code]输出结果:Hello!!!WellcometoPython'sworld!Therearealotofinterestingthings!Enjoyyourself.Thankyou!---...
http://www.jb51.net//article/15706.htm
跳转时的HTTP的状态码一般为200,301,302中的一个,下面先列出各状态码出现的情况,然后再解释各状态码有什么不同:状态码200的跳转:1.<metahttp-equiv="refresh"content="3;URL=default.aspx"/>2.Server.Transfer("default.aspx");3.URLRewrite--严格来说,这个不算是跳转,只是一种URL“欺骗”4.<a>--不知道我把这个标签也列为一种跳转会不会有人有意见状态302的跳转:Response.Redirect("default.aspx");状态301和的跳转:Resp...
http://www.jb51.net//article/15639.htm
[code]usingSystem;usingSystem.Web;usingSystem.Web.UI;usingSystem.Text.RegularExpressions;namespaceSTH.function{///<summary>///UbbCode的摘要说明。///</summary>publicclassUbbCode{Roottheroot=newRoot();HttpContextcontext=HttpContext.Current;publicUbbCode(){////TODO:在此处添加构造函数逻辑//}publicStringunhtm...
http://www.jb51.net//article/15615.htm
一般进行替换操作都这样:[code]str=str.replace(字符串一,字符串二)[/code]不难发现一个问题,如果str要循环替换很多次,下一次替换时会累加上上次替换的内容,并且全遍历一次,如果字符串二很多,替换的过程就像阶梯效果,越来越大,所以速度越来越慢。要解决这个问题只能找另外的方法替换这种表达方式。如何以更高效率代替这种操作?思路如下:每次替换完后,在下次替换时先排除这次替换的内容,累加本次替换的内容。[code]publicRegexreturnMatch(Stringstr)//匹配正则{Regexr;r=newRegex(@str,RegexOptions.Ignore...
http://www.jb51.net//article/15614.htm
PHP中预先定义好的常量:__FILE__当前正在处理的脚本文件名。如果使用在一个被包含的文件中,那么它的值就是这个被包含的文件,而不是包含它的文件名。__LINE__正在处理的文件的当前行数。PHP_VERSION表示PHP处理器的当前版本,如:'3.0.8-dev'。PHP_OSPHP处理器所在的操作系统名字,如:'Linux'。TRUE真值FALSE假值可以用DEFINE函数定义更多的常量。如,定义常量:<?phpdefine("CONSTANT","Helloworld.");echoCONSTANT;//outputs"Helloworld."?>用__FILE__和__LIN...
http://www.jb51.net//article/15587.htm
1、DateTime数字型System.DateTimecurrentTime=newSystem.DateTime();1.1取当前年月日时分秒currentTime=System.DateTime.Now;1.2取当前年int年=currentTime.Year;1.3取当前月int月=currentTime.Month;1.4取当前日int日=currentTime.Day;1.5取当前时int时=currentTime.Hour;1.6取当前分int分=currentTime.Minute;1.7取当前秒int秒=currentTime.Second;1.8取当前毫秒int毫秒=cur...
http://www.jb51.net//article/15568.htm
前台:[code]<asp:LinkButtonrunat="server"ID="lbtnUp"CommandArgument='<%#Eval("id")%>'OnClick="lbtnUp_Click">修改</asp:LinkButton>[/code]后台: [code]protectedvoidlbtnUp_Click(objectsender,EventArgse){stringid=((LinkButton)sender).CommandArgument;common.salert(id);}[/code]...
http://www.jb51.net//article/15562.htm
在后台cs文件中有个函数:[code]publicstringgetStyle(objectstyle){if((int)style==1){return"文字";}return"图片";}[/code]在前台的Repeater中要这样调用,[code]<%#this.getStyle(Eval("link_style"))%>[/code]...
http://www.jb51.net//article/15546.htm
[code]usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;publicpartialclassDefault4:System.Web.UI.Page{protec...
http://www.jb51.net//article/15545.htm
匹配中文字符的正则表达式:[\u4e00-\u9fa5]评注:匹配中文还真是个头疼的事,有了这个表达式就好办了匹配双字节字符(包括汉字在内):[^\x00-\xff]评注:可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)匹配空白行的正则表达式:\n\s*\r评注:可以用来删除空白行匹配HTML标记的正则表达式:<(\S*?)[^>]*>.*?|<.*?/>评注:网上流传的版本太糟糕,上面这个也仅仅能匹配部分,对于复杂的嵌套标记依旧无能为力匹配首尾空白字符的正则表达式:^\s*|\s*$评注:可以用来删除行首行尾的空白字符(包括空格、制表符、换...
http://www.jb51.net//article/15533.htm
