"bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server" I used the following code to connect to the bitcoin core client and encountered this error:
bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server

My configuration file: bitcoin.conf is written as follows:
Expose the RPC/JSON API
server=1
rpcbind=&quot;127.0.0.1&quot;
rpcport=8332
rpcuser=&quot;bitcoin&quot;
rpcpassword=&quot;J9JkYnPiXWqgRzg3vAA&quot;

May I ask what caused my code to report an error, and how should I solve this problem?
There are many things that can be wrong.  More details are required, like the code you mentioned.
There is a more thorough discussion on this matter here:
https://bitcoin.stackexchange.com/a/106601/113203