Latest Questions tagged String

Browse all latest questions tagged String

108
Votes
Published 19 Sep, 2022
Java - Binary to text in Java

I have a String with binary data in it (1110100) I want to get the text out so I can print it (1110100 would print "t"). I tried this, it is similar to what I used to transform my text to binary but i...

47
Votes
Published 31 Aug, 2022
Python - python string including double quote character

I have input strings that are comprised of characters, including double and single quotes " and ' [email protected]$*JU(PQ AD&^%$^@!$ %()%@@DDSFD"*")(# ABD*[email protected](%J^&@ however, when I open the above input...

102
Votes
Published 29 Jun, 2022
Python - read a text file in jupyter notebook: UnicodeDecodeError: codec can't decode byte xx

my code is so simple. in handling string on python i don't know the unicode thing. sad. f = open("~161209.txt", "r") f.read() I don't know how to fix this error code is below: UnicodeDecodeError:...

33
Votes
Published 31 Aug, 2022
Python - Replace multiple substrings of Pandas Series at once

I have a Pandas Series of golf scores with multiple substring replacements I would like to make simultaneously: Replace '+' with '' (i.e. nothing) Replace 'E' with '0' In a dictionary, I suppose t...

23
Votes
Published 23 Apr, 2022
Javascript - JavaScript equivalent of python string slicing

Is there a JavaScript equivalent to this Python method of string slicing? >>> 'stackoverflow'[1:] 'tackoverflow' I have tried: // this crashes console.log("stackoverflow".slice(1,)...

115
Votes
Published 26 Apr, 2022
Python - Python: How to determine the language?

I want to get this: Input text: "ру́сский язы́к" Output text: "Russian" Input text: "中文" Output text: "Chinese" Input text: "にほんご" Output te...

26
Votes
Published 22 Aug, 2022
Python - How can I split a string of a mathematical expressions in python?

I made a program which convert infix to postfix in python. The problem is when I introduce the arguments. If i introduce something like this: (this will be a string) ( ( 73 + ( ( 34 - 72 ) / ( 33 - 3...

54
Votes
Published 24 Aug, 2022
Python - Pandas DataFrame - Extract string between two strings and include the first delimiter

I've the following strings in column on a dataframe: "LOCATION: FILE-ABC.txt" "DRAFT-1-FILENAME-ADBCD.txt" And I want to extract everything that is between the word FILE and the ".". But I want to...

3
Votes
Published 01 May, 2022
Python - How to sort the alphabet in a list without using sorting functions?

It is not based on efficiency, and has to be done with only a very very basic knowledge of python (Strings, Tuples, Lists basics) so no importing functions or using sort/sorted

378
Votes
Published 07 Sep, 2022
Java - How to convert Strings to and from UTF8 byte arrays in Java

In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java Strin...

135
Votes
Published 01 Jul, 2022
Python - Splitting a semicolon-separated string to a dictionary, in Python

I have a string that looks like this: "Name1=Value1;Name2=Value2;Name3=Value3" Is there a built-in class/function in Python that will take that string and construct a dictionary, as though I had do...

183
Votes
Published 30 Jun, 2022
Python - Usage of unicode() and encode() functions in Python

I have a problem with encoding of the path variable and inserting it to the SQLite database. I tried to solve it with encode("utf-8") function which didn't help. Then I used unicode() function which g...

177
Votes
Published 09 May, 2022
Python - How do I change the string representation of a Python class?

In Java, I can override the toString() method of my class. Then Java's print function prints the string representation of the object defined by its toString(). Is there a Python equivalent to Java's t...

39
Votes
Published 26 Apr, 2022
Python - How to detect string byte encoding?

I've got about 1000 filenames read by os.listdir(), some of them are encoded in UTF8 and some are CP1252. I want to decode all of them to Unicode for further processing in my script. Is there a way t...

389
Votes
Published 06 May, 2022
Python - Create Pandas DataFrame from a string

In order to test some functionality I would like to create a DataFrame from a string. Let's say my test data looks like: TESTDATA="""col1;col2;col3 1;4.4;99 2;4.5;200 3;4.7;65 4;3.2;140 """ What is...