English 中文(简体)
甲型肝炎,定期进行口腔搜查,造成错误
原标题:Python, regular expression search matchobj triggers error

I somehow know that the answer to this question will be obvious, but I ve spent several days trying unsuccessfully to find out why I don t seem to be able to find the reg.exp. mach object in the script below. Here s the error messsage I get:

    subject:     Re: Why DOJ BMFEA Baton Rouge rejected Gonzalaz Pen Code 99999 death case


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Traceback (most recent call last):
  File "C:AppsUtilitiesByMarc	est_search4Sender_aaB.py", line 46, in <module>
    print fn_cull_sender_info(date_string_raw)
  File "C:AppsUtilitiesByMarc	est_search4Sender_aaB.py", line 35, in fn_cull_sender_info
    print  Line 35:  matchObj found
 str(match_obj.group(0)) =   +  str(match_obj.group(0))
NameError: global name  match_obj  is not defined

该守则如下:

import sys
import re, pdb
#pdb.set_trace()

def fn_get_srctxt_hg_datestring_rawdata_from_clipbd(): 
    this_scriptz_FULLName = sys.argv[0]
    try:
        date_string_raw = sys.argv[1]
        return returnval    
    except:
        date_string_raw =   

        import win32clipboard

        win32clipboard.OpenClipboard()
        clip_text = win32clipboard.GetClipboardData()
        win32clipboard.CloseClipboard()    

        date_string_raw = clip_text
        returnval = clip_text
        return returnval    




def fn_cull_sender_info(date_string_raw): # 
    # Do re replacements
    import re
    sender_info =  Line 29 empty 
    print  

Line 30:  date_string_raw = [starts on next line...]
  + str(date_string_raw) +  
  +  x *80 +  
 
    srchpatrn = r"(from:	 )(([A-Za-z. ]+?)(?: ))?([A-Za-z.-_0-9]+@[A-Za-z.-_0-9].+?.(?:com|org|net))"        

    matchObj = re.search(srchpatrn, date_string_raw)
    if matchObj:
        print  Line 35:  matchObj found
 str(match_obj.group(0)) =   +  str(match_obj.group(0))
        sender_info = str(match_obj.group(0))
    return sender_info


if __name__ ==  __main__ : 
    harvey = fn_get_srctxt_hg_datestring_rawdata_from_clipbd()
    print harvey
    date_string_raw = harvey
    print  ***** *50
    print  

 
    print fn_cull_sender_info(date_string_raw)

下面(案文由另一个职能产生[此处没有显示])是我在“Windows C”记号板上掌握上述密码的案文:

sender_display_name = matchObj.search(date_string_raw).group(2)#.strip() 
sender_eml =      matchObj.search(date_string_raw).group(4)

I ve spent days trying to find out what I m doing wrong. I want to capture regular expression groups 3 and 4 into string variables, e.g.

但是,由于我可以拿着 match子回来,我无法回来。

最佳回答

页: 1

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签