小编Kun*_*uni的帖子

使用共享邮箱中的c#在E#中发送电子邮件

IT部门正在从创建服务帐户转向共享邮箱.我们所有的部门电子邮件帐户都将转换为共享邮箱.到目前为止,我一直使用EWS使用以下代码从我们的网络应用程序向收件人发送电子邮件:

ExchangeService service = new ExchangeService();
service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
{
     Credentials = new NetworkCredential("dept_email@example.com", "Password1"),
     Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx")
            };

     email = new EmailMessage(service);
     email.Body = new MessageBody(BodyType.HTML, Message.ToString());
     email.ToRecipients.Add(Recipient.email);
     email.SendAndSaveCopy();
}
Run Code Online (Sandbox Code Playgroud)

如何使用共享邮箱发送电子邮件而不是硬编码电子邮件地址和密码?我使用的电子邮件地址是不符合当前密码安全标准的服务帐户.正是由于这个原因,他们正在将部门电子邮件更改为共享邮箱.

我正在使用Windows身份验证来验证Active Directory中的用户.

c# exchangewebservices

9
推荐指数
1
解决办法
4976
查看次数

如何使用 python requests 库从网络下载 PDF 文件

尝试使用请求模块从网站下载一些 pdf 文件,但我不断收到下面列出的错误。我看到了几篇文章,他们提到使用response.contentpdf 文件而不是response.text,但它仍然产生错误。不知道如何解决这个问题。

示例链接:https://corporate.exxonmobil.com/-/media/Global/Files/worldwide-giving/2018-Worldwide-Giving-Report.pdf

def scrape_website(link):
        
    try:
        print("getting content")
        cert = requests.certs.where()
        page = requests.get(link, verify=cert, headers={"User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 12871.102.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"})
        
        print(page)
        if ".pdf" in link:
            print("the content is a pdf file. downloading..")
     

            return page.content
        
        return page.text

    except Exception as x:
        print(x)
        return ''

statement_page = scrape_website(link)


with open(filepath, 'w+', encoding="utf-8") as f: 
        print("writing page")
        f.write(statement_page)
        f.close()


    <ipython-input-42-1e4771d32073> in save_html_page(page, path, filename)
     13         with open(filepath, 'w+', encoding="utf-8") …
Run Code Online (Sandbox Code Playgroud)

python download python-requests

6
推荐指数
1
解决办法
1万
查看次数

按 Chartjs 条形图的键对对象进行分组

我正在尝试使用 Chart.js 创建条形图。我在尝试根据每个用户的状态创建分组条形图时遇到了困难。所以这是数据:

[{statusId: 0, firstName: "Joe", status: "appealed", count: 1},
{statusId: 0, firstName: "Jane", status: "approved", count: 100},
{statusId: 0, firstName: "Smith", status: "approved", count: 63},
{statusId: 0, firstName: "Mike", status: "approved", count: 63},
{statusId: 0, firstName: "Ken", status: "approved", count: 35},
{statusId: 0, firstName: "Kim", status: "approved", count: 193},
{statusId: 0, firstName: "Joe", status: "approved", count: 1},
{statusId: 0, firstName: "Jane", status: "closed", count: 1},
{statusId: 0, firstName: "Joe", status: "concluded", count: 1},
{statusId: 0, firstName: "Jane", status: …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs chart.js

3
推荐指数
1
解决办法
1978
查看次数

如何从熊猫的所有列中提取字符串中的数字并取数字的中位数?

我有这个熊猫数据框:

name,a,b,c,d,e,f,g,h,i,j
"Female, n (%)",1991 (38.26%),1018 (41.52%),438 (35.12%),771 (35.16%),244 (35.72%),343 (32.48%),316 (40.51%),177 (33.84%),133 (41.18%),792 (35.92%)
"Male, n (%)",3190 (61.30%),1426 (58.16%),803 (64.39%),1415 (64.52%),436 (63.84%),711 (67.33%),463 (59.36%),345 (65.97%),187 (57.89%),1403 (63.63%)
"Age, years",44.00 [38.00 - 50.00],43.00 [37.00 - 49.00],43.00 [37.00 - 49.00],44.00 [38.00 - 50.00],44.00 [39.00 - 50.00],44.00 [38.00 - 50.00],43.00 [37.00 - 49.00],45.00 [39.00 - 51.00],44.00 [37.00 - 50.00],45.00 [38.00 - 51.00]
Run Code Online (Sandbox Code Playgroud)

我想要做的是取值的中位数,但符合以下标准:

  1. 如果该行包含(\d%),那么我想提取该值
  2. 如果该行包含[\d - \d],那么我想提取方括号前的数字。

需要注意的是,每一行都将具有相同类型的数据。

预期结果:

在此处输入图片说明

python dataframe pandas

2
推荐指数
1
解决办法
60
查看次数