string-formatting

TypeError: not all arguments converted during string formatting

為{幸葍}努か 提交于 2019-12-11 20:12:50
问题 I have a program that's supposed to calculate Hamming Code for even parity with a 7-bit integer, here is the program: data=list(input("Enter a 7-bit binary integer:")) if (data[0]+data[1]+data[3]+data[4]+data[6])%2 == 0: data.insert(8, "0") else: data.insert(8, "1") if (data[0]+data[2]+data[3]+data[5]+data[6])%2 == 0: data.insert(7, "0") else: data.insert(7, "1") if (data[1]+data[2]+data[3])%2 == 0: data.insert(6, "0") else: data.insert(6, "1") if (data[4]+data[5]+data[6])%2 == 0: data.insert

Re-arrange Axis of MS Excel 2016 Scatterplot

倾然丶 夕夏残阳落幕 提交于 2019-12-11 17:16:02
问题 Software: MS Excel 2016 Files: GitHub Repository Referring Question: MS Excel Scatterplot converts Months to Numbers I created scatterplot in month_unordered_axis.xlsx from following data Then I customized X-axis so it displays only month Unfortunately the scatterplot (in Chart1 of month_unordered_axis.xlsx) starts with October rather than January. How to order the X-axis so it displays from January to December? 回答1: Your graph is displaying October as the minimum value from its automatic

How to format text file with tab to make it readable and nice look

最后都变了- 提交于 2019-12-11 14:58:10
问题 I'm new to c# and currently I'm working on error logging where in error logs will be placed into a text file. My dilemma now is that, I cannot format the text file nicely, I mean to make it easily readable. Can you help me on this? Thanks in advance. See below code. Code for creating first row for headers if (!File.Exists(file)) { file = new StreamWriter(file); builder.AppendFormat("{0, 10} {1, 25} {2, 30} {3, 30} {4, 30} {5, 50} ", "LOGTYPE", "DATE", "COMPLEXITY", "MESSAGE", "EXCEPTION TYPE"

Display different numbers of decimals in an f-string depending on number's magnitude?

风格不统一 提交于 2019-12-11 14:48:45
问题 The goal is to use an f-string to round a float to a different number of decimal places based on the size of the number. Is there in-line f-string formatting that works like the following function? def number_format(x: float): if abs(x) < 10: return f"{x:,.2f}" # thousands seperator for consistency if abs(x) < 100: return f"{x:,.1f}" return f"{x:,.0f}" # this is the only one that actually needs the thousands seperator 回答1: Although it is not something that can go in-line in an f-string, the

iOS NSLog %hd %hhd %ld and %lld format specifiers [closed]

六月ゝ 毕业季﹏ 提交于 2019-12-11 12:15:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . What would be the meaning of these format specifiers? %hd %hhd %ld %lld 回答1: %hd is used for short integer or unsigned short integer %hhd is for short short integer or unsigned short short integer %ld is for long integer or unsigned long integer %lld is for long long integer or unsigned long long integer Simple

Convert dates string to different format with javascript

戏子无情 提交于 2019-12-11 10:59:29
问题 This is what I have in a script that is pulling events with a Google Calendar API: var datestring2 = (startJSDate.getMonth() + 1) + "/" + startJSDate.getDate(); After I append this to a list it prints out in the format 12/2 while I want it to print out Friday, Dec 2 . How can I do this? I have looked into date.js but had no luck. 回答1: There is no built in function in Javascript that can do that (I presume you are after something like PHP's date() function). You can certainly roll your own

Using Left without Copy & Paste

不想你离开。 提交于 2019-12-11 10:16:47
问题 I have some data that I want to be basically cut down to the first 12 numbers no matter how many it goes out. The way I'm currently doing it is taking the numbers from the column C and in Column G I have a formula =Left(C3,12) I then drag down so it matches the range in C. Then I run a macro that looks like this: Sub Macro6() Range("G3:G7").Select Selection.Copy Range("C3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Extending string formatting with custom conversion types

不羁的心 提交于 2019-12-11 09:26:04
问题 string.Formatter allows the extension of new style formatting with custom conversion types. Is this possible for the older "%" -style formatting strings too? Is there a library for this? 回答1: Maybe class CustomFormat(object): def __init__(self, obj): self.Object = obj def __str__(self): return str(self.Object).upper() # your magic goes here... print "abc%s" % customFormat("hello") # abcHELLO 来源: https://stackoverflow.com/questions/18394385/extending-string-formatting-with-custom-conversion

Formatting numbers in Java / Indian numbering system [duplicate]

可紊 提交于 2019-12-11 07:56:50
问题 This question already has answers here : How can I format a String number to have commas and round? (10 answers) Number formatting in java to use Lakh format instead of million format (3 answers) Closed 5 years ago . I want to obtain number in following format: 1000 = 1,000 10000 = 10,000 100000 = 1,00,000 I tried this: import java.text.DecimalFormat; public class StringProcessingDemo { public static void main(String[] args) { String pattern = "##,##,###.###"; DecimalFormat myFormatter = new

why does this NSLog code print zero's for the values?

爱⌒轻易说出口 提交于 2019-12-11 07:28:55
问题 Why does this objective-c code print 0's for the values, where as in debugger I can see they have non-0 values: Code CGRect currFrame = label.frame; currFrame.origin.y = currVertPos; currFrame.origin.x = 0; currFrame.size.height = expectedLabelSize.height; currFrame.size.width = maxWidt h; NSLog(@" currFrame dimensions:x/y/height/width = %d / %d / %d / %d", 0, currVertPos, expectedLabelSize.height, maxWidth); What is Printed currFrame dimensions:x/y/height/width = 0 / 0 / 0 / 0 回答1: Because