小编CR0*_*V3R的帖子

Python电子邮件发送TypeError:预期的字符串或缓冲区

好吧,伙计们,我已经在网上看了很多年,根本找不到答案.我尝试过很多建议,但似乎无法让它发挥作用.我正在尝试使用python(smtplib和电子邮件模块)和gmail服务发送电子邮件.这是我导入的包:

import time, math, urllib2, urllib, os, shutil, zipfile, smtplib, sys
from email.mime.text import MIMEText
Run Code Online (Sandbox Code Playgroud)

这是我发送电子邮件的def语句:

def sendmessage():
print('== You are now sending an email to Hoxie. Please write your username below. ==')
mcusername = str(raw_input('>> Username: '))
print('>> Now your message.')
message = str(raw_input('>> Message: '))
print('>> Attempting connection to email host...')
fromaddr = 'x@gmail.com'
toaddrs = 'xx@gmail.com'
username = 'x@gmail.com'
password = '1013513403'
server = smtplib.SMTP('smtp.gmail.com:587')
subject = 'Email from',mcusername
content = message
msg = MIMEText(content)
msg['From'] = …
Run Code Online (Sandbox Code Playgroud)

python typeerror smtplib

6
推荐指数
2
解决办法
8048
查看次数

列表中的Python对象是不是?

我有一个问题,试图制作一个小型的文本幻想型游戏,涉及每种类型的实体(墙,玩家,书等)的类.我有一个名为room的类,如下所示:

class Room:

    def __init__(self, desc, items, wallF, wallB, wallL, wallR, isdark):
        self.desc = desc
        self.items = items
        self.wallF = wallF
        self.wallB = wallB
        self.wallL = wallL
        self.wallR = wallR
        self.isdark = False
Run Code Online (Sandbox Code Playgroud)

现在我有两个房间,这样定义(不是说它的权利):

roomstart = Room('There is a hole in the ceiling where you seemed to have fallen through, there is no way back up...', [candle], True, False, False, False, False)
room2 = Room('You enter a small cobblestone cavort. It is dark, and the smell of rot pervades you', …
Run Code Online (Sandbox Code Playgroud)

python

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

标签 统计

python ×2

smtplib ×1

typeerror ×1