TypeError: 'in <string>' requires string as left operand, not by

TypeError: 'in string' requires string as left operand, not bytesusername roottn.wr

TypeError: 'in <string>' requires string as left operand, not bytes
username = 'root'
tn.write(username + str('\n'))

TypeError: 'in <string>' requires string as left operand, not bytes

这个错误什么原因啊,怎么解决

eclipse+pydev,环境
[解决办法]
贴出完整的错误信息...
[解决办法]
看他的解决方案是tn.write需要字节型才对,代码里的username是字符串型

引用:
你的user是byte数据,貌似跟上面的代码不太一致?
python 3.x?