1. Number of workers
|
Name |
Description |
|
Format (string, object) |
Replace the format item in the specified string with the text equivalent item of the value of the specified object instance. |
|
Format (string, array <> [] () []) |
Replace the format item in the specified string with the text equivalent item of the value of the corresponding object instance in the specified array. |
|
Format (iformatprovider, String, array <> [] () []) |
Replace the format item in the specified string with the text equivalent item of the value of the corresponding object instance in the specified array. The specified number of partitions provides specific format settings for the region. |
|
Format (string, object, object) |
Replace the format items in the specified string with the text equivalent items of the values of the two specified object instances. |
|
Format (string, object) |
Replace the format items in the specified string with the text equivalent items of the values of the three specified object instances. |
Number of shards
Int M [] = new int {a, B, c, d };
String. Format ("{0} {1} {2}", M );
Number of workers
Private const string _ extraclause = "and c_internshiporg_internshipid = {0 }";
// Use mycrypt. decrypt (request ["ID"]) as the number of partitions of _ extraclause
If (request ["ID"]! = NULL & request ["ID"]! = String. Empty)
{
Mexico tramessage = string. Format (_ extraclause, mycrypt. decrypt (request ["ID"]);
}
2. format the value result table.
Character |
Description |
Demo |
Output |
C |
Currency |
String. Format("{0: C3}", 2) |
$2.000 |
D |
Decimal |
String. Format("{0: D3}", 2) |
002 |
E |
Scientific notation |
1.20e + 001 |
1.20e + 001 |
G |
General |
String. Format("{0: g}", 2) |
2 |
N |
Number separated by semicolons |
String. Format("{0: n}", 250000) |
250,000.00 |
X |
Hexadecimal |
String. Format("{0: x000}", 12) |
C |
|
|
String. Format("{0. 000}", 12.2) |
012.200 |
String. format is used to format a string (concatenate a string based on the specified rules or output other variables and return a new string ).
String. Format (FM ,...);
The first batch number uses FM to represent the output format. Each % symbol is followed by a formatting expression, and each formatting expression corresponds to the batch number in sequence.
Therefore, if n formatting expressions are used, must they be added? N workers.
The following is a simple example:
Int = 123;
STR = "string"
-- The following % S corresponds to the number of bytes STR, % I corresponds to the number of bytes int
STR = string. Format ("this is a string :'
% S'This is a numeric value
% I",
Str,
Int);
Win. MessageBox (STR );
-- % 05i indicates the number to be formatted as at least five digits. If it is not enough, add 0 in front.
STR = string. Format ("
% 05i",
Int);
Win. MessageBox (STR );
Format expression: % [zero or multiple signs] [minimum field width] [precision] [modifier] format code
Note: [] square brackets indicate the number of optional brackets
1. format code
Code C
Number)
Meaning the number of bytes is cropped to 8-bit bytecode and printed as characters.
Code I, d
Number)
Meaning the number of digits is printed as a decimal integer. Assuming that the precision is given and the number of digits of the value is smaller than the number of digits of the precision, the front is filled with 0.
Code U, O, X, X
Number)
Meaning the number of digits is printed as an unsigned numeric value. U is in decimal format, and O is in octal format. The difference between the two is that the X Convention uses abcdef, X uses abcdef.
Code E, E
Number)
Meaning the number of dimensions is printed in exponential form. For example, 6.023000e23 uses code E and 6.023000e23 uses code E. The number of digits after the decimal point is determined by the precision field. The default value is 6.
Code F
Number)
Meaning the number of workers is printed in the regular floating-point format. The precision field determines the number of digits after the decimal point. The default value is 6.
Code G, G
Number)
Meaning % f or % E (for example, G, % E) is printed based on its value. If the index is greater than or equal to-4 but less than the precision field, the % F format is used. Otherwise, the exponential format is used.
Code s
Number of bytes string value (string)
Meaning print a string.
Code Q
Number of partitions (none)
Meaning print a string and place the string in a pair of quotes. If the string contains a line feed, do you add it manually? Escape Character. Assume that you want to read a string and pass it as the script code. To prevent malicious injection of special characters such as leading characters, % Q can be used for formatting.
Code %
Number of partitions (none)
Meaning cancel % escape print a % character, that is, % represents the original %.
2. Logo
Logo-
The meaning value is aligned in the field, which is right by default.
Flag 0
Meaning when the value is right aligned, it is not used to fill the left of the value with spaces by default. This flag indicates Zero Filling. It can be used for D, I, U, O, X, X, E, E, F, G, and G code.
When code D, I, U, O, X, and X are used, if the precision field is given, the zero mark is ignored. Assume that a negative sign is displayed in the format code, and the zero sign is ineffective.
Flag +
Meaning when used to format a signed value code, if the value is not negative, the positive sign will add a positive sign to it. If the value is negative, a negative number is displayed as usual. In
By default, the positive signs are not displayed.
Space
The meaning is only used to convert signed values. When the value is not negative, this sign adds a space? To its start position. Note that this sign and the positive sign are mutually exclusive. Assume that the two
Given at the same time, the space mark is ignored.
Flag #
There is also a form of conversion for some code:
Used for... # flag...
O ensure that the generated value starts with a zero
X and X are prefixed with 0x before non-zero values (0x for % x)
E, E, F make sure that the result always contains a decimal point, even if it is not followed by a number
G, G, and the above E, E and F code are the same. In addition, the 0 suffix is not removed from a small number.
3. Field width
The field width is a decimal integer used to specify the minimum number of characters in the current result. If the number of characters in a value is less than the field width, fill it? Length.
4. Precision
The precision starts with a period, followed by an optional decimal number. If no integer is given, the default value is zero.
For conversions of the D, I, U, O, X, and X types, the precision field specifies the minimum number in the current result and overwrites the zero sign. Assuming that the number of digits of the converted value is smaller than the width, insert zero before it. If the value is zero and the precision is zero, no number is generated in the conversion result.
For the conversion of E, E, and F types, the precision determines the number of digits after the decimal point.
For conversions of G and G types, it specifies the maximum number of valid digits in the current result.
When S type conversion is used, the precision specifies the maximum number of characters to be converted.
Assume that the decimal integer used to indicate the field width and/or accuracy is replaced by an asterisk, the width and (or) precision are provided for the next vertex number (which must be an integer) of printf. Therefore,
These values can be obtained through calculation without being specified in advance.
5. Demo
Format code a abc abcdefgh
% S a ABC abcdefgh
% 5 s #### A ## ABC abcdefgh
%. 5 S A ABC ABCDE
% 5.5 s #### A ## ABC ABCDE
%-5 s a #### ABC # abcdefgh
Format code 1-12 12345 123456789
% D 1-12 12345 123456789
% 6D ##### 1 ###-12 #12345 123456789
%. 4D 0001-0012 12345 123456789
% 6.4d ## 0001 #-0012 #12345 123456789
%-4D 1 ####-12 #12345 123456789
% 04d 0001-012 12345 123456789
% + D + 1-12 + 12345 + 123456789
Format code 1.01. 00012345 12345.6789
% F 1.000000 0.010000 0.000123 12345.678900
% 10.2d ###### 1.00 ##### 0.01 ####### 0.00 #12345.67
% E 1.000000e + 00 1.000000e-02 1.234500e-04 1.234568e + 04
%. 4e 1.0000e + 00 1.0000e-02 1.2345e-04 1.20000e + 04
% G 1 0.01 0.00012345 12345.7
Format code 6.023e23
% F 60229999999999975882752.000000
%10.2e 60229999999999975882752.00
% E 6.023000e + 23
%. 4e 6.0230e + 23
% G 6.023e + 23
The preceding Formatting Function allows you to easily convert numbers.
-- Convert digits to binary strings
STR = string. Format ("% B", 23 );
-- Convert a binary string to a number
N = tonumber (STR, 2)
-- Convert digits to octal strings
STR = string. Format ("% O", 23 );
-- Convert an octal string to a number
N = tonumber (STR, 8)
-- Convert a number to a hexadecimal string
STR = string. Format ("% x", 23 );
-- Convert a hexadecimal string to a number
N = tonumber (STR, 16)
Iv. Formatting time
The formatting time functions of the simulation genie v7.10 include string. Time; string. ftime; OS. Data; OS. Time and other functions.
OS. Time is the numeric time value generated from the table string. Time is the numeric time value generated from the string.
The OS. Data and string. ftime functions generate a string or time from the time value in turn.
Here we will introduce the string. Time Function and string. ftime function. The following is a demo:
-- Create time value from string
T = string. Time ("2006/6/6 0: 0", "% Y/% m/% d % H: % m: % s ")
-- Create a string from the Time Value
STR = string. ftime ("% Y/% m/% d % H: % m: % s", T)
Formatting syntax (applicable in many programming languages)
% A-abbreviation of the day of the week in the current region
% A-Full name of the current region day of the week
% B-abbreviation of the month in the current region
% B-Full name of the current region month
% C-the preferred datetime expression for the current region
% C-century value (year divided by 100 and then rounded up from 00 to 99)
% D-the day of the month, in decimal number (range: 01 to 31)
% D-the same as % m/% d/% Y
% E-the day of the month, in decimal number. A space (ranging from '1' to '31') is added before a digit ')
% G-same as % G, but not Century
% G-4-digit year, which is in line with the number of ISO weeks (for details, see % V ). The format and value of % V are the same, except that the number of ISO weeks belongs to the previous year or the next year, the year is used.
% H-the same as % B
% H-24 hours in decimal format (range: 00 to 23)
% I-12 hours in decimal format (range: 00 to 12)
% J-the day of the year in decimal format (ranging from 001 to 366)
% M-decimal month (range: 01 to 12)
% M-decimal minutes
% N-linefeed
% P-based on the given time value 'am' or 'pm ', or the corresponding string in the current region settings
% R-time with the.M. And p.m. symbols
% R-24 hour time
% S-decimal seconds
% T-Tab
% T-current time, same as % H: % m: % s
% U-the day of the week in decimal format [1, 7]. 1 indicates Monday.
% U-the week of the current year, starting from the first Sunday of the first week as the first day
% V-ISO 8601: 1988 format for the week of the current year, ranging from 01 to 53. Week 1st is the first week of the current year with at least four days, and Monday is the first day of each week. (% G or % G is used as the year of the week corresponding to the specified time stamp .)
% W-the week number of the current year, starting from the first Monday of the first week
% W-the day of the week, and Sunday is 0
% X-the preferred time representation for the current region, excluding the time
% X-the preferred time representation for the current region, excluding the date
% Y-there is no century in decimal year (range: 00 to 99)
% Y-decimal year containing the number of centuries
% Z-Time Zone name or abbreviation
%-Characters '%' in text