All Questions
Tagged with formatting string-formatting
276 questions
1
vote
0
answers
75
views
Python formatting float to n signficaint digits
I would like to convert a set of floats to strings with 3 significant digits, e.g.
10.00 --> 10.0
10.10 --> 10.1
101.10 --> 101
Using "{:.3g}".format(x) results in 10, 10.1, 101 ...
2
votes
3
answers
2k
views
How can I make certain text bold in Python string formatting?
I have a snippet where I generate a string that includes an original number (original_number) and its corresponding Roman numeral (roman_number). I want to format this string so that the original ...
-1
votes
1
answer
156
views
How to do string interpilation in R [duplicate]
Basically the function where you add a variable inside a string like the JavaScript template literals:
var str = "This is a sample";
print(`So you load the string in with ${str}, and it ...
-1
votes
1
answer
298
views
How to Format Lists of Strings and Dictionaries for Email Body in Python
I'm working on a Python script where I need to format three different types of lists into a string that will be used as the body of an email. The lists are as follows:
A list of strings:
a = ['1.1.1.1'...
1
vote
1
answer
73
views
Lua formatting returns unexpected results
I recently wrote a small program where I'm trying to convert a number of seconds into a more human readable format, but I'm having problems when trying to format the output and somehow I end up ...
0
votes
1
answer
457
views
In Python, is there a max length float to string formatting parameter?
I have a program that prints matrices in the console which means I want the spacing for each matrix entry to be the same, regardless of how big the number is, positive or negative. I want numbers that ...
0
votes
2
answers
144
views
Why do programmers use %s in the print statement, instead of adding the variable, which holds a specific value(string), to the print statement? [closed]
I don't understand why programmers use %s, when they can simply just add the variable name to the print statement. I mean its less work to type in the variable name instead of " ...%s" % ...
1
vote
1
answer
149
views
formatting function output similar os.date() in lua
I have a function that get current time and do some calculation that return a table. Something like this:
functuin newtime()
t1 = os.date("*t")
-- do some calculation that calculate ...
1
vote
1
answer
214
views
How to deal with month grouping and sum of hours of these months in Google Sheets?
I'm having trouble filtering a column by month/year and counting the unique values. I started trying with ARRAYFORMULA, then with QUERY, but without success.
A
B
C
D
E
F
G
Date
Start Time
End Time
...
1
vote
2
answers
205
views
Google sheets converts 01/01/0001 into 01/01/2001
How to make it stops? Tried many different formattings and it gives no difference. Could not find anything in settings. Googling only gives how to stop google sheets from auto-formatting numbers into ...
0
votes
1
answer
582
views
Format a string using dictionary unpacking (Python 3.9) [duplicate]
mystr = '{1} {0}'
mydict = {'0': '5', '1': 'ZIDANE'}
result = mystr.format(**mydict)
Which raises:
IndexError: Replacement index 1 out of range for positional args tuple
I can do the following:
...
0
votes
2
answers
342
views
Java - How to replace spaces of formatting with decimals in printf?
I would like to print out a list of items with a row of periods, or ellipsis, between the first text and final variable with a space on each side. So if the spacing is three or more, there should be a ...
0
votes
0
answers
129
views
Displaying JSON list data in a new line
I have a JSON and in that it has a list.Inside the list I want to show each data in a new line(something like /n for Java Strings) but I get all the data inside the list in a single line .Is this ...
1
vote
2
answers
190
views
Problem with formatting my f string output in Python
I am trying to get the output of my code formatted in the following way:
Expected:
1 aggc tgtc aatg
13 ctag gcat agaa
25 gtcg tgct gtag
37 agat agtc tgat
49 agtc gc
However, I always get the ...
1
vote
1
answer
48
views
How to Export all data in schedule after filled put another Sheet
How to export all the data in the schedule after filling it out and putting the data in another sheet, such as the name of the employee with its dates from the beginning of the month to the end of the ...