Skip to content
Advertisement

Tag: ascii

Can’t figure out error: “UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xdc in position 0: ordinal not in range(128)”

I have a program that is communicating with another machine that sends (or is supposed to send) ASCII characters, the code below is how I write and read code to the machine. def writeCode(send): address = ‘COM4’ I get the error on the “out+=ser.read(1).decode(‘ascii’) line. I looked online but most of the advice seems to be based around if you

How can we print a list of ASCII characters to the console, except forthose characters which have an escape sequence?

For any ascii characters ch, I would like to print ch unless repr(ch) begins with a back-slash character. I want to print a list of all of the “nice” ascii characters. Failed Attempt The console print-out is: I seem to have printed a lot of weird unicode characters, such as ç and õ Answer As sj95126 wrote: values above 127

Hexadecimal to ASCII string in Pandas

I have this pandas datafreme As you can see it’s in Hex and I need to convert it to ASCII character. Hence, I need it to look like this I can do this in plain python, but I can’t do it in Pandas. Aný help is very much appreciated Answer Use lambda function or lsit comprehension: Another idea:

Regex For Special Character (S with line on top)

I was trying to write regex in Python to replace all non-ascii with an underscore, but if one of the characters is “S̄” (an ‘S’ with a line on the top), it adds an extra ‘S’… Is there a way to account for this character as well? I believe it’s a valid utf-8 character, but not ascii Here’s there code:

Which is the character in python?

Im communicating with physical equipments via python socket. Im kinda used to doing it, but not an expert. The commands which i send to the equipments are usually found in the equipment’s manuals. Usually, commands end with CR or LF (or both) and work well when i do something like: mysocket.send((command+”rn”).encode()) With “rn” acting as CRLF (although as this answer

Data type somehow gets converted when appended to a list

I am trying to convert text to binary using ASCII encoding, and then decode the binary back to text as proof of concept for a larger project. The following code works well and does what it is supposed to do: However, as soon as I try to append the given value of output_data to a list within the for loop,

Character reading from file in Python

In a text file, there is a string “I don’t like this”. However, when I read it into a string, it becomes “I donxe2x80x98t like this”. I understand that u2018 is the unicode representation of “‘”. I use command to do the reading. Now, is it possible to read the string in such a way that when it is read

Advertisement