string-formatting

XSLT Format Date

回眸只為那壹抹淺笑 提交于 2020-01-14 09:21:08
问题 I have a date in this format 10/12/2011 12:55:00 PM (MM-DD-YYYY time) I would like to format this date into 12/10/2011 (DD-MM-YYYY) time to be removed using XSLT? the complexity I find is sometimes the input date can look like 7/12/2011 12:55:00 PM (only one number to the front instead of 07) Can someone please show me a way to implement this? many thanks in advance. 回答1: It is easy to obtain desired result using only standard XPath string functions like substring-before , substring-after and

How to edit an IBAN number in four character groups?

主宰稳场 提交于 2020-01-14 05:32:07
问题 https://en.wikipedia.org/wiki/International_Bank_Account_Number#Practicalities The IBAN should not contain spaces when transmitted electronically: when printed it is expressed in groups of four characters separated by a single space, the last group being of variable length as shown in the example below: A typical IBAN looks like this: GR16 0110 1250 0000 0001 2300 695 (taken from the above link). I want to make it easier for users to enter IBAN numbers. Currently I use a TDBEdit to display

Issue with StringFormat for small negative numbers that have been rounded

拜拜、爱过 提交于 2020-01-13 19:05:48
问题 I am trying to write a string format that will round or pad numbers to two decimal places, and also display negative numbers with brackets around them. This is in a in a WPF application, but it applies to any .net StringFormat use case. For example: 2.0 -> 2.00 -2.0 -> (2.00) 0.01 -> 0.01 -0.01 -> (0.01) 0.001 -> 0.00 -0.001 -> (0.00) The last one, a very small negative number rounded to zero, is the problem. I still want the brackets to indicate that it was negative. My first version was a

Convert int to hex with leading zeros

隐身守侯 提交于 2020-01-12 11:58:12
问题 How to convert int (4 bytes) to hex (" XX XX XX XX ") without cycles? for example: i=13 hex="00 00 00 0D" i.ToString("X") returns "D" , but I need a 4-bytes hex value. 回答1: You can specify the minimum number of digits by appending the number of hex digits you want to the X format string. Since two hex digits correspond to one byte, your example with 4 bytes needs 8 hex digits. i.e. use i.ToString("X8") . If you want lower case letters, use x instead of X . For example 13.ToString("x8") maps

Convert int to hex with leading zeros

走远了吗. 提交于 2020-01-12 11:57:05
问题 How to convert int (4 bytes) to hex (" XX XX XX XX ") without cycles? for example: i=13 hex="00 00 00 0D" i.ToString("X") returns "D" , but I need a 4-bytes hex value. 回答1: You can specify the minimum number of digits by appending the number of hex digits you want to the X format string. Since two hex digits correspond to one byte, your example with 4 bytes needs 8 hex digits. i.e. use i.ToString("X8") . If you want lower case letters, use x instead of X . For example 13.ToString("x8") maps

How to use python str.format inside a string of json format

自闭症网瘾萝莉.ら 提交于 2020-01-12 06:53:11
问题 Python Version 3.5 I'm trying to make an API call to configure a device using json as the format. Some of the json will vary depending on the desired naming, so I need to call a variable in the string. I am able to accomplish this using the old style %s... % (variable) , but not with the new style {}... .format(variable) . Failed EX: (Testing with {"fvAp":{"attributes":{"name":(variable)}}}) a = "\"app-name\"" app_config = ''' { "fvAp": { "attributes": { "name": {} }, "children": [ { "fvAEPg"

Python: Capitalize a word using string.format()

荒凉一梦 提交于 2020-01-11 19:38:11
问题 Is it possible to capitalize a word using string formatting? For example, "{user} did such and such.".format(user="foobar") should return "Foobar did such and such." Note that I'm well aware of .capitalize() ; however, here's a (very simplified version of) code I'm using: printme = random.choice(["On {date}, {user} did la-dee-dah. ", "{user} did la-dee-dah on {date}. " ]) output = printme.format(user=x,date=y) As you can see, just defining user as x.capitalize() in the .format() doesn't work,

What is the difference between !r and %r in Python?

我只是一个虾纸丫 提交于 2020-01-11 15:20:04
问题 As the title states, what is the difference between these two flags? It seems they both convert the value to a string using repr()? Also, in this line of code: "{0!r:20}".format("Hello") What does the 0 in front of the !r do? 回答1: %r is not a valid placeholder in the str.format() formatting operations; it only works in old-style % string formatting. It indeed converts the object to a representation through the repr() function. In str.format() , !r is the equivalent, but this also means that

What is the difference between !r and %r in Python?

久未见 提交于 2020-01-11 15:19:08
问题 As the title states, what is the difference between these two flags? It seems they both convert the value to a string using repr()? Also, in this line of code: "{0!r:20}".format("Hello") What does the 0 in front of the !r do? 回答1: %r is not a valid placeholder in the str.format() formatting operations; it only works in old-style % string formatting. It indeed converts the object to a representation through the repr() function. In str.format() , !r is the equivalent, but this also means that

How to use apostrophe in formatted xpath?

喜夏-厌秋 提交于 2020-01-11 11:49:02
问题 I have place the locator in properties file like : header.navigation.product.link = //div[contains(@class,'grid-')]//li/a[contains(.,'%s')] and while I'm using this locator in my code- String headerproductlink = String.format(ConfigurationManager.getBundle() .getString("header.navigation.category.link"), category) And category = Women's Gym Clothing While I'm trying to locate the element it unable to find. even i have tried as Women\'s Gym Clothing but no success. Can someone please suggest a