string-formatting

python fabric mysql privileges

杀马特。学长 韩版系。学妹 提交于 2019-12-02 02:54:00
问题 Trying to set mysql user privileges with fabric. run("mysql -u %s -p%s -e 'grant all on %s.* to '%s'@'localhost' identified by 'PASSWORD'" % (user, dbpasswd, account)) Error TypeError: not enough arguments for format string Any idea ? Thanks a lot ! run('mysql -u %s -p%s -e "grant all on %s.* to '%s\'@\'localhost' identified by 'PASSWORD'"' % (user, dbpasswd, account, account)) SyntaxError: unexpected character after line continuation character 回答1: Change your tuple to (user, dbpasswd,

FFMPEG command fails for file path with white spaces

那年仲夏 提交于 2019-12-02 02:16:58
I am executing the below ffmpeg command for trimming videos.The issue I am having is that if filepath contains spaces then the command fails.I tried many ways to handle spaces but none of them worked except moving file to a path that doesn't have space and then executing the command with new file path as source. Below is the command- execFFmpegBinary("-i " + filepath + " -ss " + startMs / 1000 + " -to " + endMs / 1000 + " -strict -2 -async 1 " + dest.getAbsolutePath()); private void execFFmpegBinary(final String command) { try { ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {

Reading float using scanf in c

假如想象 提交于 2019-12-02 02:10:00
i have a structure which contains a float variable, struct MyStruct{ float p; }newMyStruct; And i am reading a value into it using scanf int main(){ scanf("%f",&(newMyStruct.p)); } The problem is when i print it using printf("%f",newMyStruct.p) it prints '0.000000'. Also i get a warning that says the arugment is double while the format expects it to be float(warning for the scanf("%f",&(newMyStruct.p)); statement).When i change scanf() syntax to scanf("%0f",&(newMyStruct.p)); , printf("%0f",newMyStruct.p); prints the float value correctly but the compiler gives another warning(something

python fabric mysql privileges

烂漫一生 提交于 2019-12-02 00:19:31
Trying to set mysql user privileges with fabric. run("mysql -u %s -p%s -e 'grant all on %s.* to '%s'@'localhost' identified by 'PASSWORD'" % (user, dbpasswd, account)) Error TypeError: not enough arguments for format string Any idea ? Thanks a lot ! run('mysql -u %s -p%s -e "grant all on %s.* to '%s\'@\'localhost' identified by 'PASSWORD'"' % (user, dbpasswd, account, account)) SyntaxError: unexpected character after line continuation character Change your tuple to (user, dbpasswd, account, user) and you should be good. This error happens because you have 4 replacements tokens (%s) but only

Print big number in hexadecimal

亡梦爱人 提交于 2019-12-01 22:53:29
I'm trying to convert big number to hexadecimal representation in R, but it fails, because it can't fit into 32-bit integer. Is there any way to overcome this limitation? > print(0xffffffff+0x10000000) [1] 4563402751 > as.hexmode(0xffffffff+0x10000000) Error in if (is.double(x) && (x == as.integer(x))) x <- as.integer(x) : missing value where TRUE/FALSE needed In addition: Warning message: In as.hexmode(4294967295 + 268435456) : NAs introduced by coercion Luckily I found the solution, but requires library gmp library(gmp) > as.character(as.bigz(0xffffffff+0x10000000),b=16) [1] "10fffffff" 来源:

In Python 2, can I pass a list to the percent-format operator?

对着背影说爱祢 提交于 2019-12-01 21:44:01
I have a list of things I'd like to print using a format string. In Python 3-style, using "a string".format(arg,arg,arg) , this is easy. I can just replace with arguments with *mylist , like mylist = [1,2,3] "{} {} {}".format(*mylist) I can't seem to make this work with the older percent-formatting. I've tried stuff like "%i %i %i" % mylist , %i %i %i" % (mylist) , and %i %i %i" % (*mylist) but I just keep getting syntax errors or "not enough arguments". Is this impossible in 2.x style? ETA: I am changing the example above, I actually did mean list , not tuple . I'm still learning and I'm not

IFormattable.ToString not working as expected for Hexadecimal formatting

萝らか妹 提交于 2019-12-01 20:57:00
问题 String.Format and IFormattable.ToString(format, value) provides different result when trying to format to hexadecimal. How to get correct results when using IFormattable.ToString(format, value) string format = "0x{0:X4}"; Console.WriteLine(string.Format(format, 255)); //prints- 0x00FF IFormattable formattableValue = (IFormattable)255; Console.WriteLine(formattableValue.ToString(format, null)); //prints- 25x{5:X4} 回答1: The format of the formatting string is different for string.Format() and

C# string formatting with variable space alignment

落花浮王杯 提交于 2019-12-01 20:46:16
问题 I want to do something like String.Format("Completed {0:9} of ",0) + xlsx.totalCount.ToString(); except instead of hardcoding a 9 I want the alignment to be whatever xlsx.totalCount is. Any thoughts? 回答1: Try it like this: string formatString = "{0:" + xlsx.totalCount.ToString() + "}"; String.Format("Completed " + formatString + " of ", 0) + xlsx.totalCount.ToString(); 回答2: The string doesn't have to be a compile time constant, you can build the string during runtime (using a StringBuilder,

IFormattable.ToString not working as expected for Hexadecimal formatting

谁都会走 提交于 2019-12-01 20:08:32
String.Format and IFormattable.ToString(format, value) provides different result when trying to format to hexadecimal. How to get correct results when using IFormattable.ToString(format, value) string format = "0x{0:X4}"; Console.WriteLine(string.Format(format, 255)); //prints- 0x00FF IFormattable formattableValue = (IFormattable)255; Console.WriteLine(formattableValue.ToString(format, null)); //prints- 25x{5:X4} The format of the formatting string is different for string.Format() and for ToString() . In particular, string.Format() allows for other text around the format, while IFormattable

VB6 Format function: analog in .NET

て烟熏妆下的殇ゞ 提交于 2019-12-01 18:32:06
There is String.Format function that is referred to in the documentation as the analog for Format function from VB6. There's also Format function from VisualBasic namespace that is provided for compatibility and basically has same powers as String.Format . Indeed, those two format dates and numbers. But VB6's function was also able to format strings: ? format$("hi there", ">") HI THERE ? format$("hI tHeRe", "<") hi there ? format$("hi there", ">!@@@... not @@@@@") HI ... not THERE String.Format is not able to do that, as far as I'm concerned, nor is the new Format . I also couldn't find any