我有几行代码可以从 pdf 文件中提取电子邮件地址。
 for page in pdf.pages:
      pdf = page.extractText()
      # print elpdf
      r = re.compile(r'[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}')
      results = r.findall(pdf)
      Listemail.append(results)
      print(Listemail[0:])
 pdf.stream.close()
不幸的是,在运行代码后,我注意到结果并不完全好,因为每次找到匹配项时它都会出现一个 'u' 字符:
[[u'testuser1@training.local']]
[[u'testuser2@training.local']]
有人知道如何避免该角色出现吗?
提前致谢