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,530 points
0 votes
0 answers
+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,530 points
0 votes
2 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Python generates the error message you present ...READ MORE

answered Mar 14 in Python by Facts
• 140 points
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,540 points
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,000 points
+13 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,400 points
0 votes
1 answer