Python3 Format print, to take bugs from symbols

Asked

Viewed 58 times

0

import os

with open('lista.txt', 'r') as lista:
    l = lista.read().splitlines()
    for s in l:
        v = os.system('ping '+s)
        print ((v).format)

This ping works, but returns with symbols like: I saw that the staff declares the variable and puts . format, isn’t there an easier way not to put . format in everything?? and once put Unicode utf-8 pro script all understand??

Sorry mod;I can not at all format the python code here in stackoverflow

1 answer

0

Put this command in the first line of your code and it should work for everything to be utf-8:

-*- coding: utf-8 -*-

The pycharm IDE uses another similar command, but if you write this one it will ask you to fix it without problems, but in the others it should work very well.

Another way to correct in specific places is as follows:

variavel.decode('utf-8')

If it doesn’t work, inform.

  • line 8, in <module> print (v.Encode('utf-8')) Attributeerror: 'int' Object has no attribute 'Encode'

  • It was a mistake, and the first code you put, I had already tested in pycharm, he does not understand. I will try some module that does this for now

  • Just need to fix another error now, the answer is this print(Ord(v[-1])), but now from this error: Typeerror: 'int' Object is not subscriptable

Browser other questions tagged

You are not signed in. Login or sign up in order to post.