Python .findall(文本)上的语法无效,仅突出显示(或随机字母)?

Python .findall(文本)上的语法无效,仅突出显示(或随机字母)?,python,Python,当尝试运行此命令时,我得到一个“无效语法”错误,它将突出显示“t”或行中的空格 extractedPhone=phoneRegex.findall文本 有什么原因吗?仔细检查所有其他内容以确保所有内容都已打开和关闭,将文本重命名为示例,但不确定发生了什么 它的目标是从PDF中搜索电话号码和电子邮件,只需复制文件,然后运行此程序 多谢各位 #! Python3 import re import pyperclip #create a regex for phone numbers phone

当尝试运行此命令时,我得到一个“无效语法”错误,它将突出显示“t”或行中的空格

extractedPhone=phoneRegex.findall文本

有什么原因吗?仔细检查所有其他内容以确保所有内容都已打开和关闭,将文本重命名为示例,但不确定发生了什么

它的目标是从PDF中搜索电话号码和电子邮件,只需复制文件,然后运行此程序

多谢各位

#! Python3

import re
import pyperclip

#create a regex for phone numbers

phoneRegex = re.compile(r'''

((\d\d\d)|(\(\d\d\d\)))?    #area code optional
(\s | -)                    #first seperator
\d\d\d                      #three digits
(\s | -)                    #second seperator
\d\d\d\d                    #last four digits
(((ext(\.)?\s)|x)           #ext. 12345
(\d{2,5))?                  #ext optional number

''', re.VERBOSE)

#create a regex for email addresses

emailRegex = re.compile('''(
[A-Za-z0-9-_+.]+            #name part (AZaz+_-.)
@                           #@
[A-Za-z0-9-_+.]+            #domain
)''' re.VERBOSE)

#get text off the clipboard
text = pyperclip.paste()


#extract the email / phone from this text
extractedPhone = phoneRegex.findall (text) #here is the issue line
extractedEmail = emailRegex.findall (text)

allPhoneNumber = []
for numbers in extractedPhone:
    allPhoneNumbers.append(phoneNumber[0])

print (extractedPhone)
print (extractedEmail)
在这条线上


emailRegex = re.compile('''(
[A-Za-z0-9-_+.]+            #name part (AZaz+_-.)
@                           #@
[A-Za-z0-9-_+.]+            #domain
)''', re.VERBOSE) # you missed a comma here after triple-quote.

请不要回答问题,如果唯一的更正是纠正一个打字错误。