All Questions
Tagged with formatting string
1,090 questions
-4
votes
1
answer
72
views
Combine LeftPad and Truncate in String.format()
TLDR; 1 String.format(XXX, YYY) or "No this is not supported".
Add if the number is to short leading zero. If the number is to long (longer than 6) cut it.
long number1 = 123456789L;
long ...
-1
votes
1
answer
83
views
How to pass a variable in a string block?
In the following example code, I am trying to use graphql query and I have to pass the value of a string that I get from the command-line argument in the query:
package main
import (
"bytes&...
0
votes
2
answers
107
views
How do I format numbers with leading zeros efficiently in Python? [duplicate]
I have a set of floats in my script, and I'd like to print them from a method with a set number of leading zeros, and decimal points so that (for example):
0.0000 becomes 000.0000
12.1246 becomes 012....
-6
votes
1
answer
81
views
I can't get my string to display properly
So basically, the below code should display the following. "This text variable1 then this text variable2 followed by this text"
textBox1.Text = string.Format("This text {0} then this ...
0
votes
2
answers
99
views
Calling ToString with a nominated format returns Char rather than String
I am making a generic method to print an array to a delimited string, and the ToString() method is behaving strangely. Take this function:
Public Function ToString(Of T)(array() As T, delimiter As ...
0
votes
2
answers
86
views
How to format an array of numbers into a string in C#?
The method String.Format has the following overload:
public static string Format (string format, params object?[] args);
which I supposed was meant for formatting many args of the same type into a ...
0
votes
0
answers
38
views
Formatting multiplication tables in python; not how to, just some explanation
I'm meant to make a multiplication table in Python using nested loops. I had trouble formatting it to make a table and looked for answers online. I came across a solution:
uplim=int(input("What ...
0
votes
1
answer
60
views
How to convert limits of detection (or linearity) with an inferior (or superior) sign to numbers with fixed decimals in R?
Let's consider a dataframe with a column "before" as character format.
How to convert the limits of detection like e.g. "<0.5" to a number with four decimals "0.4999"...
0
votes
0
answers
38
views
How do i fix the white space format for my twoString method?
For my homework, we have to create a list that looks like this.
Employee List:
Amy Williams 6345.00
Ese Nguyen 4231.16
Jacqui Smith 1988.20
Srilatha Patel 525.00
However ...
0
votes
2
answers
425
views
How to print a paragraph into one single long line in python
Paragraph="This is a long paragraph.Its printed on a single straight line.You can zoom your screen"
print(paragraph)
When I run the program,the paragraph is printed more than one line.I want ...
1
vote
1
answer
74
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
74
views
Can someone help me understand this bit of string formatting?
I was trying a coding challenge and gave up, in the submitted answers for others I found this string formatting method.
number = 10
for i in range(1, number+1):
print("{0:{w}d} {0:{w}o} {...
0
votes
1
answer
85
views
How can I convert a set of strings and attributes into a single variable?
I want to set a variable to the coordinates of a point by combining letters and ints in C#. However, this combination was apparently considered a string and couldn't be converted implicitly.
My ...
0
votes
0
answers
82
views
printf("%d", x) alters value of %d when spaces are added to the formatted string? [duplicate]
Consider this very simple lines of code:
#include <stdio.h>
#include <stdlib.h>
typedef int board[8][8];
board * initBoard(void)
{
board * b = malloc(sizeof(board));
if (!b) { ...
0
votes
1
answer
55
views
DataFrame fails formatting when exporting data to string
Formatting is not applied when I use a for loop to assign data values.
Python 3.10.6; Pandas 1.4.4; Numpy 1.23.3
from pandas import DataFrame as DF
import numpy as np
data = np.array([[3.017088, 113....