formatting

python 3 string formatting (alignment)

旧时模样 提交于 2020-06-28 02:39:31
问题 i have a code where the out put should be like this: hello 3454 nice 222 bye 45433 well 3424 the alignment and right justification is giving me problems. i tried this in my string {0:>7} but then only the numbers with the specific amount of digits are alright. the other numbers that have some digits more or less become messed up. it is very obvious to understand why they are messing up, but i am having trouble finding a solution. i would hate to use constant and if statements all over the

Portable printing of exponent of a double to C++ iostreams

让人想犯罪 __ 提交于 2020-06-24 07:19:11
问题 I want to print a double value to std::cout portably (GCC, clang, MSVC++) such that the output is the same on all platforms. I have a problem with the formatting of the exponent. The following program #include <iostream> int main() { std::cout << 0.1e-7 << std::endl; return 0; } Has this output with GCC: 1e-08 and the following output with MSVC 1e-008 How can I make both outputs the same? I'm sorry if this is a dumb question but I have not found an answer so far. All formatting seems to

How can I get Python to use upper case letters when printing hexadecimal values?

冷暖自知 提交于 2020-06-22 13:28:32
问题 In Python v2.6 I can get hexadecimal for my integers in one of two ways: print(("0x%x")%value) print(hex(value)) However, in both cases, the hexadecimal digits are lower case. How can I get these in upper case? 回答1: Capital X (Python 2 and 3 using sprintf-style formatting): print("0x%X" % value) Or in python 3+ (using .format string syntax): print("0x{:X}".format(value)) Or in python 3.6+ (using formatted string literals): print(f"0x{value:X}") 回答2: Just use upper(). intNum = 1234 hexNum =

Combining two files into one in a specific format - Bash [closed]

痞子三分冷 提交于 2020-06-17 09:09:42
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 9 days ago . Improve this question I want to combine 3 files into 1 file in such a way format that it resembles (file1,file2) I have 2 files name.txt, price.txt Name.txt Cappuccino with Milk Chocolate Cookie Cappuccino with Double Chocolate Cookie Latte with Milk Chocolate Cookie Latte with Double Chocolate

How do I make Dartfmt “friendly” for Matrices?

荒凉一梦 提交于 2020-06-13 05:38:25
问题 For a Matrix that supposed to look like this: const ColorFilter sepia = ColorFilter.matrix(<double>[ 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0, ]); But dartfmt changed it to become like this: const ColorFilter sepia = ColorFilter.matrix(<double>[ 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0, ]); This is hard to read. Thus, how can I keep the original format so that the Matrix can be seen

How do I make Dartfmt “friendly” for Matrices?

夙愿已清 提交于 2020-06-13 05:37:29
问题 For a Matrix that supposed to look like this: const ColorFilter sepia = ColorFilter.matrix(<double>[ 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0, ]); But dartfmt changed it to become like this: const ColorFilter sepia = ColorFilter.matrix(<double>[ 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0, ]); This is hard to read. Thus, how can I keep the original format so that the Matrix can be seen

Uncrustify Collapse Multiline Function Call

穿精又带淫゛_ 提交于 2020-06-12 08:32:31
问题 I have function calls that look like this (for no apparent reason): func ( a, b, c ) Is there a way to make uncrustify collapse the function into a single line? I have been trying for two days not on and off... I got it to work for function declarations, but I don't get it to work for function calls. While we are at it I also have functions that look like so: func ( a, // (IN) the A b, // (IN) something b c // (OUT) the resulting value ) Is there a way to handle that case too, without

Uncrustify Collapse Multiline Function Call

自古美人都是妖i 提交于 2020-06-12 08:32:12
问题 I have function calls that look like this (for no apparent reason): func ( a, b, c ) Is there a way to make uncrustify collapse the function into a single line? I have been trying for two days not on and off... I got it to work for function declarations, but I don't get it to work for function calls. While we are at it I also have functions that look like so: func ( a, // (IN) the A b, // (IN) something b c // (OUT) the resulting value ) Is there a way to handle that case too, without

How to add section numbers (1.2, 3.4.1) automatically using CSS?

﹥>﹥吖頭↗ 提交于 2020-06-10 03:49:35
问题 How to add section numbers (1.2, 3.4.1) automatically using CSS? I currently have h1, h2, h3, h4 { font-weight: normal; } h1 { font-size: 140%; } h2 { font-size: 120%; color:#049;} h3 { font-size: 110%; color:#06C;} h4 { font-size: 105%; color:#09C;} How to modify them so section numbers such as 1.3, 2.4.5 are automatically constructed depending on the nesting level and order of appearance of the section headers? ... <h2>heading21</h2> ... <h3>heading31</h3> ... <h2>heading22</h2> should show

How to add section numbers (1.2, 3.4.1) automatically using CSS?

限于喜欢 提交于 2020-06-10 03:48:08
问题 How to add section numbers (1.2, 3.4.1) automatically using CSS? I currently have h1, h2, h3, h4 { font-weight: normal; } h1 { font-size: 140%; } h2 { font-size: 120%; color:#049;} h3 { font-size: 110%; color:#06C;} h4 { font-size: 105%; color:#09C;} How to modify them so section numbers such as 1.3, 2.4.5 are automatically constructed depending on the nesting level and order of appearance of the section headers? ... <h2>heading21</h2> ... <h3>heading31</h3> ... <h2>heading22</h2> should show