format

Formatting a list

混江龙づ霸主 提交于 2019-12-11 00:46:39
问题 I have the following list: (X X O NIL NIL O NIL NIL O) I'd like to format it to look like this: X | X | O --+---+-- | | O --+---+-- | | O I could probably cobble something together with what little I know about Lisp and FORMAT , but it would probably be pretty gross. Any pointers would be greatly appreciated. 回答1: * (format t "~{~A | ~A | ~A~%~^--+---+--~%~}" (mapcar (lambda (x) (or x " ")) '(X O X NIL X X O X NIL))) X | O | X --+---+-- | X | X --+---+-- O | X | NIL 回答2: * (format t "~{~A |

Python get normal HEX format for MAC-Adress

…衆ロ難τιáo~ 提交于 2019-12-11 00:13:32
问题 I want a normal format for the MAC-Address I got from get_node(). The format I get is 0x0L0xdL0x60L0x76L0x31L0xd6L, I want the 0x deleted and the L-term to a real hex number. It should be 00-0D-60-76-31-D6 . How can I realize this? def getNetworkData (self): myHostname, myIP, myMAC = AU.getHostname() touple1 = (myMAC & 0xFF0000000000) >> 40 touple2 = (myMAC & 0x00FF00000000) >> 32 touple3 = (myMAC & 0x0000FF000000) >> 24 touple4 = (myMAC & 0x000000FF0000) >> 16 touple5 = (myMAC &

Importing date-time data to excel

我的梦境 提交于 2019-12-10 23:58:10
问题 I have a txt file containing two columns. The rows look like this: 20160119,101000 Which means "19 January 2016 10:10:00" What is the easiest way to convert this date to excel's date-time data? I.e. eventually I want to get one column with date-time values. ADD: Of cause, I can do this: DATEVALUE(MID(A11;5;2) & "/" &MID(A11;7;2) & "/" & MID(A11;1;4)) + TIMEVALUE(MID(A11;10;2) & ":" & MID(A11;12;2) & ":" & MID(A11;14;2)) But what I'm looking for is some automatic way to format it on the very

python string.format, keep unused/overused keys [duplicate]

主宰稳场 提交于 2019-12-10 23:13:10
问题 This question already has answers here : python format string unused named arguments [duplicate] (9 answers) partial string formatting (16 answers) Closed 14 days ago . I have template strings with named arguments (for ex. msg = "{a} {b} {c}" ) and series of functions returning results of some statistical calculations in dictionaries. I want to use these dictionaries to fill templates. However, there is a problem. The exact number of the arguments in the template is not as same as in the

C# Export to Excel format

故事扮演 提交于 2019-12-10 21:34:17
问题 ActionResult: var strLawTable = new StringBuilder(); strLawTable.Append("<thead>"); strLawTable.Append("<tr>"); strLawTable.Append("<th style=\"text-align: right\">Dollar</th>"); strLawTable.Append("</tr>"); strLawTable.Append("</thead>"); strLawTable.Append("<tbody>"); foreach (Currency currency in Model.List) { strLawTable.Append("<tr>"); strLawTable.Append("<th style=\"text-align: right\">=\"" + GetExcellFormatString(Currency.USD) + "\"</th>"); strLawTable.Append("</tr>"); } strLawTable

How does “%tB” formatter work?

孤街浪徒 提交于 2019-12-10 21:07:38
问题 System.out.format("%tB",12); I should get a "December" out of it, however i get a nice exception Exception in thread "main" java.util.IllegalFormatConversionException: b != java.lang.Integer It means the syntax I used is wrong. I cannot find any reference on line explaining the %tB formatting command. Is anybody help to clarify the matter? Thanks in advance. 回答1: From the Formatter documentation: Date/Time - may be applied to Java types which are capable of encoding a date or time: long ,

Convert date to character in particular format In R

谁说胖子不能爱 提交于 2019-12-10 20:06:05
问题 I need to map 3-4 different dataframes that have different date formats. How can we convert date in format: YYYY-MM-DD to character in the format: MMM-YY 回答1: Create a date object from the string (skip this if your column is already in the Date format): original_date <- as.Date("2017-07-19", "%Y-%m-%d") Then format the original date to the new format: format(original_date, "%b-%y") # "Jul-17" The %b indicates the 3-letter abbreviation of the month and %y is the year without the century. You

How to validate user-supplied printf format string against parameter list?

人盡茶涼 提交于 2019-12-10 19:51:51
问题 I have a list of numbers and want to give my users the option to enter a printf-style format string to specify how the numbers should be output. How can I validate the user-supplied format string against my parameter list? Malformed input should not crash the program, and I want to avoid any format string attacks. I do not care if the validation handles just the format options specified in POSIX or the compiler specific superset. Is there any library call to do this, or will I have to write

R xts converts numbers to strings - why?

筅森魡賤 提交于 2019-12-10 19:18:22
问题 When I convert to a xts object, R changes the values from numbers to strings, which causes problems: timeseries <- xts(timeseries,as.POSIXct(timeseries$Date)) timeseries <- timeseries[endpoints(timeseries,ts_ret_freq)] This is the code in question. Why is this the case? It shouldnt be. Thanks in advance. 回答1: Because an xts object is essentially a matrix object. Hence all the columns of the xts will always be of same datatype (class) 来源: https://stackoverflow.com/questions/15635590/r-xts

custom format for decimal c#

不打扰是莪最后的温柔 提交于 2019-12-10 18:05:33
问题 I'm trying to format a decimal value with decimals to a custom format without comas or points , Having checking http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx but can't find the format I need I need to convert a decimal value for example 3.1416 to 314 or even better 0000000314, any clue? 回答1: To scale by 100 and show up to 9 leading zeros use String.Format("{0:0000000000}", (value * 100)); 回答2: For just display String.Format("{0:##########}", (value * 100)) 回答3: Make a simple Method