format

How to change date format from DD/MM/YYYY to YYYY-MM-DD? [duplicate]

天大地大妈咪最大 提交于 2019-12-04 04:27:53
问题 This question already has answers here : How to reformat date in PHP? (9 answers) Closed 3 years ago . How to change format of date string using PHP? From: 06/16/2010 To: 2010-06-16 回答1: $date = "06/16/2010"; echo date('Y-m-d', strtotime($date)); // outputs 2010-06-16 Using the strtotime function. 回答2: You should use \DateTime and get rid of strings as soon as possible: $date = DateTime::createFromFormat('m/d/Y', '06/16/2010'); // \DateTime object echo $date->format('Y-m-d'); // 2010-06-16

Parameterizing format specifier in printf

柔情痞子 提交于 2019-12-04 03:58:30
问题 I have a few lines of output like the following: printf("%-20s %-20s %-20s %-20s %-20s \n", "Identity", "Identity", "float", "double", "long double"); printf("%-20s %-20s %-20s %-20s %-20s \n", "Number", "LHS", "error", "error", "error"); As you can see, if I wanted to change the spacing between them, I would have to change the number 20 ten times. Is there a way to parameterize the format specifier? So that changing only once would change them all? 回答1: Yes, you can make the field width an

How to get rid of unwanted spacing in Fortran's print output?

爷,独闯天下 提交于 2019-12-04 03:54:34
问题 It may look like a trivial issue, but I couldn't find any answer through googling. I have this little program : Program Test_spacing_print Integer:: N Real:: A,B N=4; A=1.0; B=100.0 print*,'N =',N print*,'A =',A,' B =',B print '(2(A3,F8.2,1X))' ,'A =',A,' B =',B print 20, A,B 20 format('A =',F8.2,x,'B =',F8.2) End Program Test_spacing_print which gives me the output: N = 4 A = 1.00000000 B = 100.000000 A = 1.00 B 100.00 A = 1.00 B = 100.00 I want to get rid of the unwanted space that I get

suppress Name dtype from python pandas describe

别来无恙 提交于 2019-12-04 03:44:58
Lets say I have r = pd.DataFrame({'A':1 , 'B':pd.Series(1,index=list(range(4)),dtype='float32')}) And r['B'].describe()[['mean','std','min','max']] gives an output : mean 1.0 std 0.0 min 1.0 max 1.0 Name: B, dtype: float64 But from the above output , how should I get rid or suppress the last line " Name:B, dtype: float64 " I figured out one way to achieve this x=r['B'].describe()[['mean','std','min','max']] print "mean ",x['mean'],"\nstd ",x['std'],"\nmin ",x['min'],"\nmax ",x['max'] which gives the desired output : mean 1.0 std 0.0 min 1.0 max 1.0 Is there any cleaner to achieve this output

How do I print a dataframe in R will all decimal values

坚强是说给别人听的谎言 提交于 2019-12-04 03:32:11
问题 I have a dataframe whose values I want to inspect, but when I print the dataframe, only 2 or 3 decimals are printed. I inspected the dataframe directly and confirmed that there are more decimal places than what is being printed. So far I have tried print(df, digits=10) and options(digits=10) but these don't seem to be changing the print output. Some screenshots: Printed output with too few decimals Actual data with all decimal values 回答1: I do not exactly know how you load your data. However,

Using a variable as a prefix argument to a format directive

梦想与她 提交于 2019-12-04 03:31:46
问题 I need to print something with variable number of spaces before it. For example if I need to print 5 spaces before my text, I will do: (format T "%5T My Text") Output: My Text In place of 5, can I use a variable and be able to pass on a value to it? What I am looking for is like: (format T "%(~d)T My Text" 5) output: My Text 回答1: Try (format T "~vT My Text" 5) See 22.3 Formatted Output: In place of a prefix parameter to a directive, V (or v ) can be used. In this case, format takes an

How to find the position of Central Directory in a Zip file?

风流意气都作罢 提交于 2019-12-04 03:23:45
I am trying to find the position of the first Central Directory file header in a Zip file. I'm reading these: http://en.wikipedia.org/wiki/Zip_(file_format ) http://www.pkware.com/documents/casestudies/APPNOTE.TXT As I see it, I can only scan through the Zip data, identify by the header what kind of section I am at, and then do that until I hit the Central Directory header. I would obviously read the File Headers before that and use the "compressed size" to skip the actual data, and not for-loop through every byte in the file... If I do it like that, then I practically already know all the

Mysql date warning data truncated

血红的双手。 提交于 2019-12-04 03:23:14
问题 I'm having an interesting issue with Mysql DATE format. I have this table : | id | int(11) | NO | PRI | NULL | auto_increment | | file_path | varchar(255) | YES | | NULL | | | date_export | date | YES | | NULL | | When i'm updating a row using the date function : NOW(), the date is updated with this format : '2014-01-23' But when i'm using another date format, like hand-written one like : update backup_conf_allied set date_export='2014-23-01' where file_path='IDF-952584-SW1' ; The date_export

String has how many parameters

与世无争的帅哥 提交于 2019-12-04 03:04:52
Before using String.Format to format a string in C#, I would like to know how many parameters does that string accept? For eg. if the string was "{0} is not the same as {1}", I would like to know that this string accepts two parameters For eg. if the string was "{0} is not the same as {1} and {2}", the string accepts 3 parameters How can I find this efficiently? Rubens Farias String.Format receives a string argument with format value, and an params object[] array, which can deal with an arbitrary large value items. For every object value, it's .ToString() method will be called to resolve that

Python 2.6+ str.format() and regular expressions

六月ゝ 毕业季﹏ 提交于 2019-12-04 02:46:47
问题 Using str.format() is the new standard for formatting strings in Python 2.6, and Python 3. I've run into an issue when using str.format() with regular expressions. I've written a regular expression to return all domains that are a single level below a specified domain or any domains that are 2 levels below the domain specified, if the 2nd level below is www... Assuming the specified domain is delivery.com, my regex should return a.delivery.com, b.delivery.com, www.c.delivery.com ... but it