私は行ごとにこのエラーが発生しました。理解できない `if`文に構文エラーがありますか?
SyntaxError: invalid syntax
で、emailRegex
は完全なコード(python3.x)
import re, openpyxl, os, sys
def sort_email_from_xl():
loc = input("Please enter path of the file:")
os.chdir(loc)
file = input("Filename:")
wb = openpyxl.load_workbook(file, use_iterators=True)
sheet = input("Which Sheet do you want to email?\n")
return sheet
wb.get_sheet_by_name(sheet)
ws = wb.get_sheet_by_name(sheet)
emailRegex = re.compile(r".*?([a-zA-Z0-9\._%+\-][email protected][a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4}).*?")
customeremails = [] #works fine till here in idle
for row in ws.iter_rows():
for cell in row:
if cell.value and isinstance(cell.value, str) emailRegex.match(cell.value):
mail = emailRegex.match(cell.value)
if mail:
mail = mail.group(0) # use parentheses to call the function
cell.text = mail
customeremails.append(mail)
print(customeremails)
if cell.value and isinstance(cell.value, str) emailRegex.match(cell.value):
を強調します誰かが私は正確に何であるか読み取ることができるリソースを指すことができます間違っている?私はSOからの助けを借りて、そしてdocsを通して読んで、この機能をほぼ12時間にわたって整理しようとしています。
コードは現在のエラーの後に問題ありませんか?
おかげ
あなたのコードを校正してください。 – TigerhawkT3
[セル内のテキストを正規表現にマッチさせ、正規表現にマッチするテキストのみを保持するには?](http://stackoverflow.com/questions/41779655/how-to-match-text-in-a-cell) –