有人可以帮我从我的交换账户发送电子邮件,并添加附件。 SMTP不起作用,我得到即时超时问题。 0365不会将副本保存到我发送的文件夹中。 我唯一知道的另一个是exchangelib from exchangelib import Account, Credentials, Message, Mailbox, FileAttachment from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText from email.utils import formatdate from email import encoders email = 'XXXXXXXX' password = 'XXXXXXXX' a = Account(email, credentials=Credentials(email, password), autodiscover=True) dir_path = ('C:/Users/Istcrmt/Documents/Python/PythonforAnaconda3.5/') excel_name = 'test.xlsx' #attach an excel file: for […]
我正在从一个Excel工作表中提取数据并将数据存入数据库的学校项目。 运行下面的代码并运行SQL命令SELECT * FROM items后,它将返回“空集”。 我究竟做错了什么? 我在这里先向您的帮助表示感谢! import openpyxl import MySQLdb as mdb db = mdb.connect('localhost', 'root', 'TRM4611', 'practice') cur = db.cursor() wb_choice = input('What workbook would you like to use?\n–> ') wb = openpyxl.load_workbook(wb_choice + '.xlsx') all_sheets = wb.get_sheet_names() with db: for sheet in all_sheets: current_sheet = wb.get_sheet_by_name(sheet) print ('\nCurrent Sheet: ' + current_sheet.title) […]
场景:我想出来一个Python代码读取给定文件夹中的所有工作簿,获取每个数据,并将其放到一个数据框(每个工作簿成为一个数据框,所以我可以单独操纵它们)。 问题1:使用此代码,即使我正在使用正确的path和文件types,我不断收到错误: File "<ipython-input-3-2a450c707fbe>", line 14, in <module> f = open(file,'r') FileNotFoundError: [Errno 2] No such file or directory: '(1)Copy of Preisanfrage_17112016.xlsx' 问题2:我创build不同数据框的原因是每个工作簿都有一个单独的格式(行是我的标识符,列是date)。 我的问题是,这些工作簿中的一些工作表上有一个名为“closures”,或“打开”或没有指定的名称表的数据。 所以我会尝试单独configuration每个dataframe,然后再join它们。 问题3:考虑到dataframe数据已经统一后的最终输出,我的目标是以如下格式输出它们: date 1 identifier 1 value date 1 identifier 2 value date 1 identifier 3 value date 1 identifier 4 value date 2 identifier 1 value date 2 identifier 4 […]
我目前正在将PDFS转换为巨大文件夹中的文本,然后将某些关键字输出到Excel文件中。 一切工作正常,除了即使我有我的文件夹中的多个PDFS,他们都写在列A1对方。 如何迭代它,以便下一个字典进入后续行? custData = {} def data_grabbing(pdf): row = 0 col = 0 string = convert_pdf_to_txt(pdf) lines = list(filter(bool,string.split('\n'))) for i in range(len(lines)): if 'Lead:' in lines[i]: custData['Name'] = lines[i+2] elif 'Date:Date:Date:Date:' in lines[i]: custData['Fund Manager'] = lines[i+2] elif 'Priority:' in lines[i]: custData['Industry'] = lines[i+2] custData['Date'] = lines[i+1] custData['Deal Size']= lines [i+3] elif 'DEAL […]
所以我现在有这样的字典设置: Dict = {'customer1': {datetime.datetime(2017, 6, 15, 14, 34, 55): '12', datetime.datetime(2017, 6, 16, 14, 34, 55): '14'}, 'customer2': {datetime.datetime(2017, 6, 16, 14, 34, 55): '16', datetime.datetime(2017, 6, 17, 14, 34, 55): '18'}} 我想打印的是这样的: ——— 15/06/2017 16/06/2017 17/06/2017 customer1 12 14 — customer2 16 18 我想过创造另一个温度。 字典。 先按datesorting,然后按顾客名称sorting,然后交叉引用这两个清单。 我确实设法创造另一个字典。 看起来像这样: tempDict = {datetime.datetime(2017, 6, 15, […]
我正在写一个parsing程序,在一些关键字后search超过100个.log文件,然后将这些单词放在不同的数组中,并将这些单词分隔到excel中的列中。 现在我想在Access中自动sorting,这样我就可以处理不同的.log文件组合。 我可以从我的Excel文件复制粘贴到Access,但效率低下,出现一些错误…我希望它是“自动”的。 我是新来的Access和不知道如何链接从Python到Access,我已经尝试做,因为我做了Excel,但没有工作,并开始寻findOBDC,但有一些问题在那里… import glob # includes import xlwt # includes from os import listdir # includes from os.path import isfile, join # includes def logfile(filename, tester, createdate,completeresponse): # Arrays for strings response = [] message = [] test = [] date = [] with open(filename) as filesearch: # open search file filesearch = […]
在下面的代码片段中,我试图在Python中打开并优化工作表,然后执行一些计算。 该代码适用于Python 2.X,但是我在Python 3.0实现方面遇到了问题。 尝试运行代码时,出现错误ValueError: Cannot convert <Cell 'Sheet1'.A1> to Excel 你能告诉我如何解决这个代码与Python 3.6的工作 这是我迄今为止的代码: import openpyxl from openpyxl import load_workbook import os # import pandas as pd import xlwings as xw os.chdir("C:/Users/boss/Desktop/for_Interns/Code") wb= openpyxl.load_workbook("F2_copy.xlsx") wb.create_sheet(index=0,title='Summary') sumsheet= wb.get_sheet_by_name('Summary') print('Creating Summary Sheet') for sheet in wb.worksheets: for row in sheet.iter_rows(): for cell in row: if cell.value=='failed': my_values= […]
我有在Excel中的数据如下 category size1 size2 size3 cat1 10 20 30 cat2 20 10 15 cat3 30 20 10 我想要两个报告/ excel输出如下 #1) Category-sizetype-value cat1 size1 10 cat1 size2 20 cat1 size3 30 cat2 size1 20 … #2) Category-size-value-value counts(ie how many time specific size value appears) cat1 size1 10 3 times cat1 size2 20 2 times cat1 […]
我有一个在Excel中的表格和参数头的数字。 看起来像这样,我只需要使用从A到E的单元格(并忽略所有其他单元格)。 正如你所看到的,F在标题行中,但我需要select特定的单元格进行迭代(如上所述)。 ABCDEF 1 50 30 10 5 1 String 2 Oval, Round NaN Irregular Nan Nan String2 3 Circumscribed NaN Nan Nan Obscured, Microlobulated 4 High density NaN Equal Nan Fat-containing 我需要分别创build两个数组到cols头。 例如,如果它是第二行,我需要有一个输出为两个数组: prob_arr = [50, 50, 10] val_arr = ['Oval', 'Round', 'Irregular'] 而对于第三排应该是: prob_arr = [50, 1, 1] val_arr = ['Circumscribed', 'Obscured', […]
我用python 2.7从网站上抓取数据,之后我把它们导出为excel。 但我在Excel中得到一个格式问题:在网站有:“9/18”,我在Excel中得到“18.sept”。 我怎样才能将这些值保存为“9/18”格式? 在这里我的代码: filename=r'output.csv' resultcsv=open(filename,"wb") output=csv.writer(resultcsv, delimiter=';',quotechar = '"', quoting=csv.QUOTE_NONNUMERIC, encoding='latin-1') f = open('0910000511.txt', 'r') x = f.read() soup = BeautifulSoup(x, 'lxml') datatable=[] for ctable in soup.find_all('table', "ctable" )[:-1]: for record in ctable.find_all('tr'): temp_data = [] for data in record.find_all('td'): temp_data.append(data.text.encode('latin-1')) datatable.append(temp_data) tab6col = soup.find('table', { "class" : "tab6col" }) datatable2=[] for record […]