Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I need to convert the format of this number:
CB0D8A83 7FBC1D22 86388A2D AFA0B9A1
I read this number:
ciphertext= (ser.read(45))
print(ciphertext)
Ciphertxt_file.write(ciphertext)
to this format:
cb0d8a837fbc1d2286388a2dafa0b9a1
I would be very grateful if yo could help me.
Simply convert them to lowercase with .lower() and remove the whitespace with .replace(' ',''):
result = ciphertext.lower().replace(' ','')
No need to use advanced tools here. This is however not a binary format (the binary format uses zeros and ones like 00110101101110). Furthermore this method does not check the format so 1134ZZ223 would be accepted as well.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
This is my string
word = " Saturday Fortune 08-09-2022 (4872) Draw Numbers "
But I only want to print the date in the string like this
'08-09-2022'
So how can I achieve this?
Should use a regular expression to find that part in the string. Something like:
import re
match = re.search(r'\d{2}-\d{2}-\d{4}', word)
This already seems to be answered as a subproblem in this thread.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 months ago.
Improve this question
I have a text file containing bits so it’s like „1000101011010110000…“ in this text. I want python to interpret this text as bytes and perform different byte transformations with it. But how do I red it on as bytes without python thinking it’s a string?
The built-in int function has an parameter base for specifying the base.
To convert a string into an integer with base 2 (binary), pass 2 into it:
s = input()
num = int(s, 2)
# Manipulate `num` as you like
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
How can I separate data types in a string or list so they can be set to another character, I assume there is something I have missed but everything i have tried so far has now worked for me. so far have tried so split into list and use a for loop to find every int but I can't find a way to differentiate the data types so it can change every int.
You can use regex :
import re
re.sub("\d", "_", "10 4 2")
\d matches any decimal digit character.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Why is not filter the df like in the screenshot
Show the function of str.contain("|") that's didn't work
You need to set the regex parameter of contains to False. In your code now, the string "|" is parsed as a regular expression, but you want to match the literal pipe character.
movies_with_more_dir = movies_df[movies_df['director'].str.contains("|", regex=False)]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
enter image description hereI am working on building a model on movie review datsets, i have recieved data set in the form of numbers as object type, I have tried astype and pd.to_numeric to convert from string to int but failed to do so.
Kindly help me with this.
Thanks in Advance,
Karim
#azro is correct. In order to convert a string to int via int() you have to make the string one int by getting rid of the white spaces with either many ints: string.split(" "), or one int: string.replace(" ", "")