Erreur TypeError: a bytes-like object is required, not 'str'
Bonjour, voila je voudrais savoir comment faire pour éviter cette erreur.
Sur Linux j'aoute cela # -*- coding: Utf-8 -*- en entete et ca marche
par contre sur windows avec IDLE python 3.5.2 sur windows je suis oblige d'ajouter encode(encoding='utf_8') ça enlève l'erreur
ne peut pas encoder d'une maniere globale comme sur linux
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| import socket
import sys
import time
server = "irc.toto.org"
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print ("connecting to:"+server)
irc.connect((server, 6667)) #connects to the server
irc.send(("USER "+ toto+" "+ toto+" "+ toto+" \n").encode(encoding='utf_8')) #user authentication
irc.send(("NICK "+ totoo+"\n").encode(encoding='utf_8')) #sets nick
...
... |
Merci