Tagged Questions
2
votes
1answer
47 views
How to compare two percentages in python?
I am new to python and I am dealing with some csv files. To sort these files, I have to compare some percentages in string format, such as "5.265%" and "2.1545%". So how do I compare the actual values ...
-4
votes
3answers
71 views
How will I convert this int into a string in an if statement?
I am making a simple text based game and have gotten an error. I have to convert the int in my code into a str. My code looks like this:
tax1 = input("You May Now Tax Your City. Will You? ")
...
0
votes
1answer
38 views
seperating numbers from letters; python
I want to seperate numbers from letters. I tried it like this, but it won't work with negative numbers. What do i have to change?
match = re.match(r"([0-9]+(?:.[0-9]+)?)([a-z]+)", "-0.5m", re.I)
...
-8
votes
0answers
47 views
How to find potential password strings script? [closed]
Can anyone help me to write a script or an approach to find potential passwords from files like .doc,docx,txt,aspx.
14
votes
8answers
517 views
Strip out numbers from a string
We have a bunch of strings for example: c1309, IF1306, v1309, p1209, a1309, mo1309.
In Python, what is the best way to strip out the numbers? All I need is: c, IF, v, p, a, mo from above example.
-1
votes
3answers
52 views
python matching list items
I'm using python 2.6
current output
mylist = [('log:A', '1009.2'), ('log:B', '938.1'), ('log:C', '925.7'), ('log:C', '925.7')]
I'am trying to add the values to produce the follow:
Ranked highest to ...
0
votes
1answer
60 views
Replace a blank space followed by text with a blank space using string replace
I have a log file from which i am trying to remove all the unwanted text except the digits(0-9). I am able to use string.replace('','') function to remove everything and get the desired, however, at a ...
0
votes
8answers
63 views
String index out of range error?
Hello I'm having a bit of difficulty understanding why the string index is listed as 'out of range.' Consider the string which I'm trying to translate in this code:
a = str("g fmnc wms bgblr ...
1
vote
2answers
50 views
Simple string encounter
How would I take a string and only take up to a certain point in the string?
If I have the string:
testSetting = f"C:\Users\bgb\Documents\Brent\Code\Variable\Visual Studio\Local.testsettings"
The ...
0
votes
2answers
45 views
How to read JUST filenames of a directory in python and then do the same job for all?
I have a python script which has this line at the very beginning to read from an input data file:
x,y = genfromtxt('data1.txt').T
Then I proceed and do the processing on x,y (it depends on a ...
0
votes
4answers
33 views
Looping through a 2d list
Hi i have a 2d list that reads
items = [(1,20),(2,30),(3,40),(4,50),(5,60),(7,80),(8,90)]
What i want to do is create a loop that loops over the 2d list and takes each pair i.e 1,20 and writes ...
1
vote
2answers
57 views
Python convert a paritcular string to dict
The format of string is like "a:1 b:2 c:x d:2.13e-5", is there some way to convert it to python dict quickly and simply?
-------------- edit line --------------
According the great answers, I tried ...
0
votes
2answers
61 views
Trying to find word count in a text file using a different text file as “dictionary”
I have a vocabulary file that contains words I need to find in other text documents. I need to find how many of each word is found, if any. For example:
vocabulary.txt:
thought
await
thorough
away
...
0
votes
2answers
27 views
how to get the order in a list of the most similar string in python
I want to compare a string with a list of other string and get the most similar. I can do it with difflib in python. But, what I want to do is get the order in the list.
from difflib import ...
0
votes
1answer
36 views
File name string not working
In my program when I call this filename:
msTestPrompt = r'"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\MSTest.exe"'
It doesnt work, it says the filename, directory name or ...