由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - pattern search question in Python
相关主题
Python:How to replace 2 different patterns in 1 line in fileCS本质上是服务业
今天去interview, 被一个老印搞掉了How many people use design patterns when coding?
请帮忙看一个python string comparion的问题,有包子.design patterns到底有用吗?
python的re怎么有很多莫名奇妙的行为, 我估计是bug吧快速系统学习 c++ design pattern有什么好书或者网站吗
a python question感觉用python的人,属于程序员中的文艺青年那类的
没觉得Java比Python和Perl有啥优点看C码工写Python真是捉急
问个PYTHON烂问题python要把@当作矩阵乘法算符
求推荐Machine Learning经典教材Java is back
相关话题的讨论汇总
话题: ads话题: adsk话题: python话题: line话题: abcde
进入Programming版参与讨论
1 (共1页)
w*s
发帖数: 7227
1
want to see if "ads" is in this line, but don't want to see "adsk".
so "ads abcde" is good
"adsk abcde" is bad
for now my code is like this,
for line in lines:
if (my_word+"\s" in line):
my_word is either "ads", or "adsk"
it's not even reporting "ads".
how to fix it pls ?
c********1
发帖数: 421
2
import re;
hasAds = re.compile(r"ads[^k]")
for line in lines:
if (hasAds.match(line) is not None):
......
1 (共1页)
进入Programming版参与讨论
相关主题
Java is backa python question
学python的一点小感觉哈没觉得Java比Python和Perl有啥优点
阅读scala中问个PYTHON烂问题
谁知道这个嵌套的Python if 是啥意思?求推荐Machine Learning经典教材
Python:How to replace 2 different patterns in 1 line in fileCS本质上是服务业
今天去interview, 被一个老印搞掉了How many people use design patterns when coding?
请帮忙看一个python string comparion的问题,有包子.design patterns到底有用吗?
python的re怎么有很多莫名奇妙的行为, 我估计是bug吧快速系统学习 c++ design pattern有什么好书或者网站吗
相关话题的讨论汇总
话题: ads话题: adsk话题: python话题: line话题: abcde