All Questions
Tagged with python-3.6 string
66 questions
0
votes
1
answer
955
views
Does Python's split function splits by a newline or a whitespace by default
I am learning Python. In particular, i read about the python string's split method and came to know that the default separator for split is a whitespace. So i understand how the following works:
text =...
0
votes
1
answer
772
views
How to send in python params (which is string) into SQL question on DB2
I want to write function which receive parameter as string which should be used inside SQL statement for DB2 database. Then I need to take row by row and do smth in each loop step:
import ibm_db
...
0
votes
1
answer
36
views
How do I add to strings in a list? (scraping links off Amazon)
I'm trying to scrape links off of Amazon. I ran into a tiny problem.
I wish to add a particular string 'a' to every string in a list.
links = soup.find_all("a", attrs= {"class"...
0
votes
1
answer
51
views
Incomprehensible string encoding python
I'm lost with string encoding, I've a CSV file of French cities, and certain cities have special caracters such : é ç and è so I got some a lot of strings like this Péron, Saône and Étienne, I ...
0
votes
1
answer
26
views
Find a string using python3
How I could solve this error:
if pattern[i] == txt[i]: IndexError: string index out of range
txt = "ABCDCDC"
pattern = "CDC"
count = 0
i = 0
for index in range(0, len(txt) + 1):...
0
votes
3
answers
65
views
how to fix the worrd in the table column?
I am extracting a table from a website. I tried already with Pandas and BeautifulSoup.
Here is an example of a code i tried:
res = requests.get("https://www.dasoertliche.de/Themen/...
2
votes
4
answers
2k
views
why Python3 str(bytes) converts to literal string b'<str>'
I am using python3. Following is example which explains question.
# python3
Python 3.6.8 (default, Sep 26 2019, 11:57:09)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "...
0
votes
0
answers
48
views
str.readline() with colored standard output catch startswith()
I need to parse a logfile that prints colored output in this format:
<0x1b[32sometexthere[0m
I'm reading the logfile in with:
line = logfile.readline()
and then I want to get it if it starts ...
0
votes
1
answer
157
views
Making a random string based on random.random and a frequency table
I have this code:
base_distribution = {'A' : 0.345, 'C' : 0.158, 'G' : 0.059, 'T' : 0.437}
def get_random_uniform_sequence(alphabet, k):
'''It return a random uniform distribuited sequence based ...
0
votes
1
answer
196
views
Element-wise manipulation of a two dimensional list in python
I am writing a script to find meeting time for three people. I manage to get their Free/Busy status encoding in a binary format with 0 being free and 1 being busy in increment of 30 minutes for the ...
1
vote
3
answers
483
views
split string and integer in specific length python
Good day Everybody, I have question, is there away to split the data into fixed length ?
suppose
data=...
0
votes
2
answers
84
views
calling functions in python 3 from within a function
Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end ...
17
votes
1
answer
5k
views
Dynamically Formatting Floats to Variable Decimal Places Using f-strings in Python [duplicate]
I've previously asked about dynamically adjusting the number of decimal places in a float when formatting with f-strings in Python. While I found similar questions that address aspects of dynamic ...
0
votes
2
answers
2k
views
slice string skip specific character
I have a string like this in python3:
ab_cdef_ghilm__nop_q__rs
starting from a specific character, based on the index position I want to slice a window around this character of 5 characters per side. ...
1
vote
1
answer
223
views
How to get the output of an Object function as Variable
I am new to this and trying pass the output of this function as a string to the tweepy update method ( To post as a statue )
def hello():
name = str(input("Enter your ...