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 = subprocess.run(['ping', adress], capture_output=True)
            print(response.stdout.decode())
            f_out.write(response.stdout)

Mar 26, 2020 in Python by skaailet
• 120 points
639 views

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
2 answers

How to solve the error - ssl module not found?

Hey, @There, nstall the necessary packages for Python ...READ MORE

answered Oct 23, 2020 in Python by Gitika
• 65,910 points
2,164 views
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, 2020 in Python by MD
• 95,440 points
12,760 views
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, 2020 in Python by MD
• 95,440 points
2,328 views
0 votes
0 answers

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

tree = [[[5, 1, 2], [8, -8, ...READ MORE

Sep 6, 2020 in Python by MUHAMMAD
• 160 points

retagged Sep 7, 2020 by Gitika 997 views
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, 2020 in Python by MD
• 95,440 points
2,468 views
+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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,503 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP