formatting

Visual Studio Code Formatting fail on save

社会主义新天地 提交于 2020-04-12 09:42:52
问题 I've started learning React Native. I'm using Visual Studio Code as my editor. I've set up the boiler plate and started the app. But whenever I change a .js file and hit save, VSCode is messing up all the formatting. I thought I could sort this in the settings.json file but after googling for a while and playing around I can't find the correct setting. Is this a bug or am I doing something wrong? Setting file is default one: UPDATE: I re-installed vscode. Then set up a basic js file with a

Using variables in the format() function in Python

余生颓废 提交于 2020-04-05 15:27:50
问题 Is it possible to use variables in the format specifier in the format()-function in Python? I have the following code, and I need VAR to equal field_size: def pretty_printer(*numbers): str_list = [str(num).lstrip('0') for num in numbers] field_size = max([len(string) for string in str_list]) i = 1 for num in numbers: print("Number", i, ":", format(num, 'VAR.2f')) # VAR needs to equal field_size 回答1: You can use the str.format() method, which lets you interpolate other variables for things

How do I reference sqlite db column to use in update statement

两盒软妹~` 提交于 2020-03-25 07:41:13
问题 I am trying to update a datetime column in an android sqlite db to use international date format (yyyy-mm-dd) instead of the current format ( mm/dd/yyyy ). I want to use the sqlite date() function to reformat the current value of the column. I thought it would be as simple as the following: update tblename set thedate = date(thedate) but the above does not work. How would i write the sql statement to accomplish this? thanks patrick 回答1: DATE() doesn't understand your old date format. The

Plotly: How to format text (underline, bold, italic)

冷暖自知 提交于 2020-03-23 23:52:48
问题 I try to underline text in plotly when using annotations. I add my annotations using import plotly.graph_objects as go g = go.FigureWidget(make_subplots(rows=1,cols=1)) g.update_layout(annotations=[dict(text='my text')]) #plus any other parameters Is there an option (in the annotations dict, maybe?) to have underlined text? Thanks! 回答1: Plotly uses a subset of HTML tags to format text like bold '<b></b>' and italics '<i></i>' . Alas, '<u></u>' does not seem to be included at the moment. But

Plotly: How to format text (underline, bold, italic)

只愿长相守 提交于 2020-03-23 23:52:26
问题 I try to underline text in plotly when using annotations. I add my annotations using import plotly.graph_objects as go g = go.FigureWidget(make_subplots(rows=1,cols=1)) g.update_layout(annotations=[dict(text='my text')]) #plus any other parameters Is there an option (in the annotations dict, maybe?) to have underlined text? Thanks! 回答1: Plotly uses a subset of HTML tags to format text like bold '<b></b>' and italics '<i></i>' . Alas, '<u></u>' does not seem to be included at the moment. But

How to parse this text file format into CSV format?

孤者浪人 提交于 2020-03-22 06:39:08
问题 I have a text file laid out as such where every field is a new line: id = 606149 Category Name = Structural Columns Family Name = Concrete-Square-Column Type Name = EXIST RH C1 16 x 16 Document = 15050 Peavy Struct v2016_detached Attachment Justification At Top = Minimum Intersection Image = <None> Offset From Attachment At Top = 0 id = 606151 Category Name = Structural Columns Family Name = Concrete-Square-Column Type Name = EXIST RH C2 16 x 16 Document = 15050 Peavy Struct v2016_detached

Format decimal to two places or a whole number

浪尽此生 提交于 2020-03-18 03:08:02
问题 For 10 I want 10 and not 10.00 For 10.11 I want 10.11 Is this possible without code? i.e. by specifying a format string alone simlar to {0:N2} 回答1: decimal num = 10.11M; Console.WriteLine( num.ToString( "0.##" ) ); 回答2: It seems to me that the decimal precision is intrinsic to the decimal type, which defaults to 4 decimal places. If I use the following code: decimal value = 8.3475M; Console.WriteLine(value); decimal newValue = decimal.Round(value, 2); Console.WriteLine(newValue); The output

Format decimal to two places or a whole number

家住魔仙堡 提交于 2020-03-18 03:07:04
问题 For 10 I want 10 and not 10.00 For 10.11 I want 10.11 Is this possible without code? i.e. by specifying a format string alone simlar to {0:N2} 回答1: decimal num = 10.11M; Console.WriteLine( num.ToString( "0.##" ) ); 回答2: It seems to me that the decimal precision is intrinsic to the decimal type, which defaults to 4 decimal places. If I use the following code: decimal value = 8.3475M; Console.WriteLine(value); decimal newValue = decimal.Round(value, 2); Console.WriteLine(newValue); The output

R output without [1], how to nicely format?

狂风中的少年 提交于 2020-03-08 07:52:49
问题 I know stuff has been posted, but not as complete as what I am looking for. Take any help function (i.e. ?mean ), and realise that it's output (or at least output should be able to be generated in the same manner). How do you get enters, alignment/intendation? Example: strings <- c("t", "df", "p-value", "mean of x", "mean of y") values <- c(t, df, pvalue, mean1, mean2) If this would be the things you'd want to output in R (when called from a function), how do you make the [1] disappear, and

Using a variable as a Save file name ~ im.save(type, '.png')

匆匆过客 提交于 2020-02-23 06:35:08
问题 This is what I'm inputting: type = 'filename' im.save(type, '.png') and what this is supposed to do is save the file in a .png format but with the variable as the name, I'm just not 100% sure how the format/syntax is supposed to be laid out. Is it the same as if I wanted to print the variable: Print(type, "This shows up beside the type I think") edit, Don't pay to much attention to the list, it's mostly there as an example. I not sure how to have a variable right beside a Plain text word like