Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: a bytes-like object is required, not 'str' #36

Open
ismadevjs opened this issue Jul 27, 2021 · 3 comments
Open

TypeError: a bytes-like object is required, not 'str' #36

ismadevjs opened this issue Jul 27, 2021 · 3 comments

Comments

@ismadevjs
Copy link

how to fix it ?

@AzizAlqasem
Copy link

AzizAlqasem commented Aug 8, 2021

I have similar problem whenever I try to read emails. I am using python 3.9
The full error message:

>> print(mail.unread())

TypeError Traceback (most recent call last)
in
----> 1 mail.unread()

~/Downloads/outlook-master/outlook.py in unread(self)
154
155 def unread(self):
--> 156 list = self.unreadIds()
157 latest_id = list[-1]
158 return self.getEmail(latest_id)

~/Downloads/outlook-master/outlook.py in unreadIds(self)
132 def unreadIds(self):
133 r, d = self.imap.search(None, "UNSEEN")
--> 134 list = d[0].split(' ')
135 return list
136

TypeError: a bytes-like object is required, not 'str'

Thanks

@shuishen49
Copy link

每当我尝试阅读电子邮件时,我都会遇到类似的问题。我正在使用 python 3.9 完整的错误信息:

>> print(mail.unread())

类型错误回溯(最近通话最后一个) 中 ----> 1个mail.unread()

~/Downloads/outlook-master/outlook.py in unread(self) 154 155 def unread(self): --> 156 list = self.unreadIds() 157 latest_id = list[-1] 158 return self.getEmail(latest_id) )

~/Downloads/outlook-master/outlook.py in unreadIds(self) 132 def unreadIds(self): 133 r, d = self.imap.search(None, "UNSEEN") --> 134 list = d[0] .split(' ') 135 返回列表 136

类型错误:需要类似字节的对象,而不是“str”

谢谢

you shuld ues py2.7
or
like this
list = d[0] .split()

replace all split like this.

@HerronYang
Copy link

Yes, it is about the version of Python. If u are at 3.x, u can also use 'decode()' to covert byte to str.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants