How to solve UTF-8 error

0 votes

Hi, im getting a problem when executing a scrip in python 
im trying to Ping a list of IP and capture the output in other text file, but im getting this error 

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 311: invalid start byte

this is my script 

import subprocess
with open('IP-list.txt', 'rb') as f, open('ip_out.txt', 'wb') as f_out:
        for adress in f:
            adress = adress.strip()
            response =['ping', adress], capture_output=True)

Mar 26 in Python by skaailet
• 120 points

Hey, @Skaallet,

 Do you have any string data in the dictionary? Then that can't be encoded or decoded.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
0 answers

How to solve the error - ssl module not found?

I am getting this error while trying ...READ MORE

Aug 8, 2019 in Python by Waseem
• 4,540 points
0 votes
1 answer

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

answered Apr 27 in Python by MD
• 56,780 points
0 votes
1 answer

How to solve the urllib.error.URLError

Hi@Jefferson, You need to use the read function in your ...READ MORE

answered Jul 15 in Python by MD
• 56,780 points
0 votes
0 answers
0 votes
1 answer

when I run this, I get NameError: name 'state' is not defined error. How to solve this?

Hi@MUHAMMAD, I tried to run the exact code ...READ MORE

answered Sep 8 in Python by MD
• 56,780 points
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 57,640 points
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer