format

Formating UUID String without REGEXP_REPLACE and PL/SQL

可紊 提交于 2019-12-20 03:10:30
问题 I'd like to format the result of the sys_guid() function such as proposed in this answer select regexp_replace(rawtohex(sys_guid()) , '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})' , '\1-\2-\3-\4-\5') as FORMATTED_GUID from dual From performance reasons I'd like to avoid the usage of regexp_replace (as I process large number of records). My scenario can be simplified to this use case: select rawtohex(sys_guid()) GUID from dual connect by level <= 2; Obviously I can't use

SQL Format Time Object From 24 Hour to 12

試著忘記壹切 提交于 2019-12-20 03:04:22
问题 Is there a way to convert a time object to a 12 hour format in SQL? I can't nessessarilly use datetime because the data being retrieved is not specific for dates. 16:45:00 --> 4:45 PM 回答1: Try using this: DECLARE @aux NVARCHAR(8)='16:45:00' SELECT CONVERT(VARCHAR(15),CAST(@aux AS TIME),100) 来源: https://stackoverflow.com/questions/11745958/sql-format-time-object-from-24-hour-to-12

Python3 - Use a variables inside string formatter arguments

主宰稳场 提交于 2019-12-20 03:03:36
问题 I have some formatted columns that I'm printing. I would like to use the following variables to set the lengths in my .format arguments number_length = 5 name_length = 24 viewers_length = 9 I have print('{0:<5}{1:<24}{2:<9}'.format(' #','channel','viewers'), end = '') Ideally I would like something like print('{0:<number_length}{1:<name_length}{2:<viewers_length}'.format( ' #','channel','viewers'), end = '') But this gives me an invalid string formatter error. I have tried with % before the

Formatting data from an excel sheet in MATLAB

半腔热情 提交于 2019-12-20 03:01:17
问题 I import data from an excel file using the command xlsread . The data look like the following: I would like to format these data so that the output looks like: A = [NaN 1 2 3; 20160101 100 80 90; 20170101 150 90 200] In excel, I would use a Pivot table. Is there an equivalent in MATLAB or how would I start to code this? Is reshape an option here? 回答1: I'll assume you are reading your data from the file as follows: data = xlsread('your_file.xls'); Which gives you a numeric matrix containing

Format, 2 decimal places for double and 0 for integer in java

雨燕双飞 提交于 2019-12-20 02:13:13
问题 I am trying to format a double to exact 2 decimal places if it has fraction, and cut it off otherwise using DecimalFormat So, I'd like to achieve next results: 100.123 -> 100.12 100.12 -> 100.12 100.1 -> 100.10 100 -> 100 Variant #1 DecimalFormat("#,##0.00") 100.1 -> 100.10 but 100 -> 100.00 Variant #2 DecimalFormat("#,##0.##") 100 -> 100 but 100.1 -> 100.1 Have any ideas what pattern to choose in my case? 回答1: The only solution i reached is to use if statement like was mentioned here: https:

EditText custom string formatting

牧云@^-^@ 提交于 2019-12-20 00:41:38
问题 I searched every question similar to my problem but didn't get it working. My problem is this: I want to format a string in EditText while typing. The format is this ( it's always a 19 digit number ): 012345 01 0123456789 0 As you can see I want to add spaces when they are needed while the user is typing. I know that I have to use the TextWatcher but everything I do I don't get what i want. Edit : Here is the code of my last try: @Override public void afterTextChanged(Editable s) { if(s

Cannot Figure out how String Substitution works in Python 3.x [closed]

梦想的初衷 提交于 2019-12-19 20:49:36
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . In python 2.x you were allowed to do something like this: >>> print '%.2f' % 315.15321531321 315.15 However, i cannot get it to work for python 3.x, I

Format a number to always have a sign and decimal separator [duplicate]

喜欢而已 提交于 2019-12-19 19:53:43
问题 This question already has answers here : Custom numeric format string to always display the sign (6 answers) Closed 5 years ago . I want to format any number (integer or real) to a string representation which always has a sign (positive or negative) and a decimal separator , but no trailing zeroes. Some samples: 3.14 => +3.14 12.00 => +12. -78.4 => -78.4 -3.00 => -3. Is it possible with one of the default ToString() implementations, or do I need write this myself? 回答1: Try something like this

MissingFormatArgumentException error

一曲冷凌霜 提交于 2019-12-19 18:10:51
问题 I have been successful in compiling my inventory program: // Inventory.java part 1 // this program is to calculate the value of the inventory of the Electronics Department's cameras import java.util.*; import javax.swing.*; import java.awt.event.*; import java.io.*; public class Inventory { public static void main(String[] args) { // create Scanner to obtain input from the command window Scanner input = new Scanner (System.in); String name; int itemNumber; // first number to multiply int

Printing each item of a variable on a separate line in Python

不羁的心 提交于 2019-12-19 17:47:02
问题 I am trying to print a list in Python that contains digits and when it prints the items in the list all print on the same line. print ("{} ".format(ports)) here is my output [60, 89, 200] how can I see the result in this form: 60 89 200 I have tried print ("\n".join(ports)) but that does not work. 回答1: Loop over the list and print each item on a new line: for port in ports: print(port) or convert your integers to strings before joining: print('\n'.join(map(str, ports))) or tell print() to use