The problem of python regularization

clipboard.png

-sharp! /usr/bin/env python
-sharp -*- coding:utf-8 -*-
from  selenium  import webdriver
from lxml import etree
import xml.dom
from config import *
import xlrd
import re
class qichacha:
     def __init__(self):
         option=webdriver.ChromeOptions()
         option.add_argument("--start-maximized")
         option.add_argument("--headless")
         self.driver=webdriver.Chrome(chrome_options=option)
     def read_data(self):
         try:
             with open("data.xls","r")as f:

                print(f.read())
                str=f.read()
                company_name=re.findall(r"""<ss:Cell><.*?>(.*?)</ss:Data></ss:Cell>""",str)
                print ("asdasdasd")
                print (company_name)
                -sharp for name in company_name:
                -sharp     if name=="":
                -sharp         pass
                -sharp     else :
                -sharp        print (name)






         finally:
             if f:
                 f.close()
         pass

if  __name__=="__main__":

    qichacha().read_data()





the print here is empty. Why is that? I think there is nothing wrong with my rules, thank you!

Mar.17,2021

if you guess correctly, the problem with these two sentences of code

print(f.read())    -sharp 
str=f.read()       -sharp  str 

try this instead:

str=f.read() 
print(str)
Menu