Skip to main content

All Questions

Tagged with
2 votes
1 answer
34 views

How to make a proper code injection statement for a simulation?

I'm currently working in a group project where we are simulating a code injection attack on a simulated smart device, specifically a light bulb. the way this works is using an HTML page with the ...
Nathan Rasmussen's user avatar
0 votes
0 answers
41 views

Passing a dataframe column value as a function argument

I'm new to Python so this should be pretty basics but I can't seam to accomplish what I want. Let's say I have the following data frame: df = pd.DataFrame(index=[1,2,3]) df['Currency'] = ['USD','USD','...
Raven 969's user avatar
1 vote
1 answer
64 views

determine position of an inserted string within another

Following this post I managed to put together a small function to place within a bigger text body (FASTA) shorter strings determined from another file based on some conditions (e.g. 100 events from a ...
Matteo's user avatar
  • 273
0 votes
1 answer
32 views

Printing string item prints individual characters

I have a text file with five lines. I open and read the lines into an array then print the array successfully but when I print a single item in the array it prints individual characters. I need to use ...
Jim Harvey's user avatar
0 votes
2 answers
97 views

how to randomly add a list of sequences into a text body

This is one of my first tasks with actual Python code. What I need to do is to import a set of (FASTA) sequences, select those with a length between 400 and 500 (base pairs) characters, and randomly ...
Matteo's user avatar
  • 273
0 votes
2 answers
104 views

Custom sorting a single string

I have a list of five-character strings, each string representing a hand of five playing cards. I want to sort each string so it's in ascending order by number, followed by the cards (T,J,Q,K,A). So “...
Peter4075's user avatar
0 votes
0 answers
57 views

Why does my last printed line disappear when using \r in VS Code terminal

why in this code in the vs code the last output cleared I think we should have "...." ?? from time import sleep c=1 while c<5 : print("."*c+"\r",end='') sleep(...
Mikel91's user avatar
0 votes
0 answers
40 views

Why does \t produce different numbers of spaces in Python output? [duplicate]

In this code I use \t as tab but in one of them the out put has 8 spaces and in one of them the out put has 7 spaces instead tab(\t) how python calculate this how should we know how many spaces we ...
Mikel91's user avatar
0 votes
0 answers
89 views

How to efficiently use NumPy's StringDType for string operations (e.g., joining strings)?

I'm trying to perform string operations with NumPy's StringDType. As an example, I've attempted to join strings with a separator row-wise. In the past, NumPy's string operations were somewhat slower ...
Olibarer's user avatar
  • 383
4 votes
0 answers
97 views

Re-construct a string from a probability distribution of substrings

I was working on practice problems for a job-interview, and I came across this problem that stumped me. The Problem The task is to reconstruct a string of a specific length from a probability ...
Who Die's user avatar
  • 41
-2 votes
2 answers
61 views

How do I find a string after finding a different string in a large text file? [closed]

I have a large text file and would like to use Python extract a line after matching a string in a preceding line. I can easily match the beginning string of a line with startswith(), but I want to ...
DH___'s user avatar
  • 7
0 votes
0 answers
36 views

Converting data into spacy format "convert_to_spacy_format" in Name entity recognition Model

Dataset structureCan somebody help me with the NER model in converting the data into spacy format. The dataset format is shown in the screenshot here (https://www.kaggle.com/datasets/naseralqaydeh/...
Rohit Gupta's user avatar
-3 votes
5 answers
136 views

Repeat the characters based on the preceding number in a string [closed]

I am a beginner in python and this is how I approached to the solution: I have divided the string into two lists- number list and character list. And then I multiplied them. Is there any other better ...
Lilly's user avatar
  • 13
-5 votes
1 answer
69 views

Returning strings and floats in python functions [closed]

I need to make a function that returns a sentence with variables in it. But how do I exclude all the special string characters that I don't need? (e.g. ( or , or ') ef area_of_triangle( bottom, height ...
Icode15promax's user avatar
0 votes
1 answer
66 views

Can I specify the replacement character in str([value], encoding='utf-8', errors='replace')

Is it possible to specify the replacement character used by str(xxx,encoding='utf-8', errors='replace') to be something other than the diamond-question-mark character (�)? I am attempting to fix up a ...
Jim JR Harris's user avatar

15 30 50 per page
1
2 3 4 5
2172