用python逐行讀取文件,取需要的字段保存到excel中
import openpyxl
def main():
workbook = openpyxl.load_workbook("new.xlsx")
sheet = workbook['Sheet1']
with open("Url.txt", 'r', encoding='utf8') as file:
readline = file.readline()
while readline:
if readline.find('\"') >= 0:
resultstr = readline.split('\"')[1]
row = [resultstr, ]
sheet.append(row)
readline = file.readline()
workbook.save("new.xlsx")
workbook.close()