Skip to content
Advertisement

The output is not displayed correctly formatted when i get output with ssh connection remotely with python script

I connect to remote server with ssh with my python codes. I connect and get results. But results are coming with rn My codes are below :

JavaScript

The output i get is like;

import osrnimport socketrnrnimport timernrnstart_time = time.time()rnrn

But i want the out put to be printed out as below

import os import socket

import time

start_time = time.time()

Advertisement

Answer

By default data in s.before is of bytes, not str. You can decode when printing:

JavaScript

You can ask it to automatically convert the data to str by specifying an encoding:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement