今天看到一个有趣的正则表达式,是用来判断一个数是否为质数。说到这儿肯定有人犯迷糊了,正则是用来匹配字符串的呀,怎么可以用来验证数字呢? 别急嘛,首先我们得做一个转换,把数字转换成字符。假定需要验证的数字是N,转换的基本字符为1,那么转换出来的字符串就是N个1。这个用Python是挺容易实现的,只需要'1'*N就可以了。
标签
360safe addon admin aggregation apple applescript archlinux avatar bash blog book bug camera chrome comic conditional required contract cpu css db dbus debug desktop diff django dns doc douban downgrade dropbox emacs feature field firefox fix font framework freelancer game google google wave greasemonkey grep gtd hal hg html5 ie ilife ios java javascript join jquery libxml libxslt linode log lxml mac meld mercurial mirror mobile movie msn mysql net nginx nintendo openbox open source openssl osx otaku pacman patch paypal pdf phone photo plugin postgresql python recaptcha restructuredtext roadmap rxvt sae search server sina snippet social network sphinx sqlserver sudo svn tutorial twisted twitter uliweb upgrade video vimeo virtualenv vps wave web2.0 web框架 windows xcode xmas xml youtube 世博 中文 云储存 交通 产品 伟大 伪娘 冷笑话 分区 合同 囧 围脖 地球日 女优 婚纱 媒体 字符串 安全 安全卫士 家乐福 密码 尝鲜 市场 废话 开源 微博 快男 总结 手机 手柄 效率 数字化 新闻 时事 时间 春运 更新 杯具 正则 正则表达式 流氓 漏洞 照片 电影 破解 维护 自由工作者 语言 越光宝盒 趣事 趣闻 键盘 防火墙 降级 陷阱 雪 验证码 鲜果热文

