i have an array called MAC1_Val:
MAC1_Val
array([ 1.00000000e+00, -1.00000000e+01, -2.06306600e+02,
2.22635749e+02, 1.00000000e+00, 1.00000000e+01,
1.00000000e+01, -2.06306600e+02, 2.22635749e+02,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
...
Good day,
I've ran into a problem with opening a file with randomly generated name in Python 2.6.
import random
random = random.randint(1,10)
localfile = file("%s","wb") % random
Then I get an error message about the last line
TypeError: unsupported operand type(s) for %: 'file' and 'int'
I just couldn't figure this out by m...
I have a localized string which needs to take a few variables. However, in localization it is important that the order of the variables can change from language to language.
So this is not a good idea:
NSString *text = NSLocalizedString(@"My birthday is at %@ %@ in %@", nil);
In some languages some words come before others, while in ...
I have a string that looks like this:
CALDARI_STARSHIP_ENGINEERING
and I need to edit it to look like
Caldari Starship Engineering
Unfortunately it's three in the morning and I cannot for the life of me figure this out. I've always had trouble with replacing stuff in strings so any help would be awesome and would help me understand...
When formatting a string, my string may contain a modulo "%" that I do not wish to have converted. I can escape the string and change each "%" to "%%" as a workaround.
e.g.,
'Day old bread, 50%% sale %s' % 'today!'
output:
'Day old bread, 50% sale today'
But are there any alternatives to escaping? I was hoping that using a di...
I want to list all numbers from 0000-9999 however I am having trouble holding the zero places.
I tried:
for(int i = 0; i <= 9999; ++i)
{
cout << i << "\n";
}
but I get: 1,2,3,4..ect
How can I make it 0001,0002,0003....0010, etc
...
Looking for best practice advice on what string substitution technique to use when using gettext(). Or do all techniques apply equally?
I can think of at least 3 string techniques:
1) Classic "%" based formatting:
"My name is %(name)s" % locals()
2) .format() based formatting:
"My name is {name}".format( locals() )
3) string.Templa...
This question is relaetd to This question, on using some of the windows explorer features automatically inside a Delphi application.
Is there a way to format an integer using the metrix prefixes automatically in Delphi? Somehow to automatically obtain a result like windows explorer gives? I mean converting 1024 to 1.0 K automatically.
...
Okay, I know I must be doing something incredibly stupid here. Here's the sample code (which, when executed within a viewDidLoad block silently crashes... no error output to debug console).
NSMutableArray *bs = [NSMutableArray arrayWithCapacity:10];
[bs addObject:[NSNumber numberWithInteger: 2]];
NSLog(@"%@", [bs count]);
[bs release];...
I have the date format string dd-mm-yy. Please can you tell me how to add hours and minutes to the string (i.e 13-03-2010.21.03) ....
DateTime.Today.ToString("dd-mm-yy") ?
...
I may have string like,
"""Hello, %(name)s,
how are you today,
here is amount needed: %(partner_id.account_id.debit_amount)d
"""
what would be the best solution for such template may i need to combine regular expression and eval, input string may differ like $partner_id.account_id.debit_amount$ - for the moment I've kept as python st...
Is there a cool way to take something like this:
Customer Name - City, State - ID
Bob Whiley - Howesville, TN - 322
Marley Winchester - Old Towne, CA - 5653
and format it to something like this:
Customer Name - City, State - ID
Bob Whiley - Howesville, TN - 322
Marley Winchester - Old Towne, CA - 5653
Using ...
I'm trying to do this:
commands = { 'py': 'python %s', 'md': 'markdown "%s" > "%s.html"; gnome-open "%s.html"', }
commands['md'] % 'file.md'
But like you see, the commmands['md'] uses the parameter 3 times, but the commands['py'] just use once. How can I repeat the parameter without changing the last line (so, just passing the...
What is the format string modifier for char-as-number?
I want to read in a number never exceeding 255 (actually much less) into an unsigned char type variable using sscanf.
Using the typical
char source[] = "x32";
char separator;
unsigned char dest;
int len;
len = sscanf(source,"%c%d",&separator,&dest);
// validate and proceed....
Hi, I am using:
from __future__ import division
To perform a division in which I need some percision. However, it gives a long number, like:
1.876543820098765
I only need the the first two numbers after "." => 1.87
How can I do that?
...
Hello,
In the code below, I would like to make the word that prints out as the variable "$submittor" a hyperlink to "http://www...com/.../members/index.php?profile=$submittor" .
I can't get it to work; I think I'm doing the formatting wrong.
How can I do it?
Thanks in advance,
John
echo '<div class="sitename3name">Submitted by '.$s...
I'm trying to ouput an array of numbers as a string in MATLAB. I know this is easily done using num2str, but I wanted commas followed by a space to separate the numbers, not tabs. The array elements will at most have resolution to the tenths place, but most of them will be integers. Is there a way to format output so that unnecessary tra...
I am using the following code to show percentage using String.Format but I also want to limit the number of significant figures to 2, the two don't seem to play well together. How can I get the two working together properly?
String.Format("% Length <= 0.5: {0:0%}", m_SelectedReport.m_QLT_1);
So what I ideally want is something like t...
If I have something like:
Decimal moneyAmount = -1522;
and then call
moneyAmount.toString("c");
It will return something like:
($1,522)
Instead, I wish for there to be a negative sign and no paraenthesis. How can I modify what format provider I send to toString() so I can achieve the following effect:
-$1,522
...
I've heard that using StringBuilder is faster than using string concatenation, but I'm tired of wrestling with StringBuilder objects all of the time. I was recently exposed to the SLF4J logging library and I love the "just do the right thing" simplicity of its formatting when compared with String.format. Is there a library out there th...