format

Python TypeError: not enough arguments for format string

戏子无情 提交于 2019-12-27 10:37:34
问题 Here's the output. These are utf-8 strings I believe... some of these can be NoneType but it fails immediately, before ones like that... instr = "'%s', '%s', '%d', '%s', '%s', '%s', '%s'" % softname, procversion, int(percent), exe, description, company, procurl TypeError: not enough arguments for format string Its 7 for 7 though? 回答1: Note that the % syntax for formatting strings is becoming outdated. If your version of Python supports it, you should write: instr = "'{0}', '{1}', '{2}', '{3}'

strptime returning NA values [closed]

≯℡__Kan透↙ 提交于 2019-12-27 01:21:30
问题 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 4 years ago . I'm trying to use strptime to format dates I'm reading in but only get NA values are returned in the output. My raw data is in the format of 1974-01-01, and the length of the dataset is 12049 so the last date is 2006-12-31. The code I use is: Data$date.yyyymmdd <- as.POSIXct(strptime(Data$date.yyyymmdd, format =

C printf cross-platform format without warnings [duplicate]

半世苍凉 提交于 2019-12-26 07:18:09
问题 This question already has answers here : Platform independent size_t Format specifiers in c? (3 answers) Closed 2 years ago . How do you write code to compile cross-platform without warnings. For example, I don't get warnings on x64 platform, but I do on ARM (raspberry PI): warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘size_t {aka unsigned int} Needless to say I don't want to disable warnings. More examples and scenarios: warning: format ‘%lu’

Format date by provided time zone in java

杀马特。学长 韩版系。学妹 提交于 2019-12-25 20:01:24
问题 I need to format date time in java for provided time zone. E.g. mm/dd/yyyy for US and dd/mm/yyyy for DE. I have time zone and i can get zoneId, can someone help me. Many thanks. 回答1: Use the modern Java date and time classes for everything that has got to do with dates or times. DateTimeFormatter usFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) .withLocale(Locale.US); System.out.println(date.format(usFormatter)); DateTimeFormatter deFormatter = DateTimeFormatter

Java Change Date Format [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-25 19:39:17
问题 This question already has answers here : How to get Date in the same format as String (2 answers) Closed 3 years ago . I want to change my Date object format. I looked other topics but always Date converted to String. I have this one: String datee=unitdata[i].toString(); Date dater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(datee); String smp= new SimpleDateFormat("MM").format(dater); SimpleDateFormat df = new SimpleDateFormat("MM"); Date date = df.parse(smp); x[i]=date; date

how can I remove special character from phone number in swift? [duplicate]

余生颓废 提交于 2019-12-25 18:34:05
问题 This question already has answers here : remove \\u{e2} characters from string (3 answers) Closed 10 months ago . When I copy number phone from phone app I get results like this \u{e2}05xxxxxx49\u{e2} I need to remove this character \u{e2} from the left and right of the number to get a result like this 05xxxxxx49 var str = number str = str!.replacingOccurrences(of: "\u{e2}", with: "") print(str!) 回答1: thanks for all finally I know how is it 👇👇👇👇 var number = self.myTFForNumber.text self

Convert one date format into another in PHP

旧巷老猫 提交于 2019-12-25 18:32:26
问题 Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date('Y-m-d H:i:s', $middle); // returns 1970-01-01 00:00:00 But I'd of course like it to return a current date rather than the crack 'o dawn. What am I doing wrong? 回答1: The second parameter to date() needs to be a proper timestamp (seconds since January 1, 1970). You are passing a string,

How to convert string of type YY/MM/DD to java.util.Date?

╄→尐↘猪︶ㄣ 提交于 2019-12-25 18:12:09
问题 I have searched but did not find the exact format(YY/MM/DD) for parsing the String. How can I convert a string of type YY/MM/DD to java.util.Date . I have strings in the format "160310", "160211". 回答1: You can use SimpleDateFormat for this. String target = "160211"; DateFormat df = new SimpleDateFormat("yyMMdd", Locale.ENGLISH); Date result = df.parse(target); For more options and info you can always checkout the full documentation about it here: http://docs.oracle.com/javase/8/docs/api/java

Java parse date from TextField with a different format [duplicate]

跟風遠走 提交于 2019-12-25 17:07:44
问题 This question already has answers here : Parsing String into mysql Date [duplicate] (4 answers) Closed 2 years ago . I'm facing some problems in Eclipse with dates. I'm showing a date in a TextField with the format dd/MM/yyyy and I need to get the text from this textfield and parse it as a date to insert it in my database into a column of type DATE I'm using MySQL and it accepts dates as yyyy-MM-dd I tried really many options, both with LocalDate or the older Date , but didn't find a solution

Cant fromat String to Date

纵然是瞬间 提交于 2019-12-25 15:16:33
问题 When I try to convert a string value to a Date I get the error message "Invalid date" timestamp : string = "2017:03:22 08:45:22"; . . let time = new Date(timestamp); console.log("Time: ",time); //here I get Time: Invalid date 回答1: Since your string must be in ISO date format you can change it like in the code below: let timestamp : string = "2017:03:22 08:45:22"; let timestampISO : string = timestamp.replace(':','-').replace(':','-').replace(' ','T'); let time = new Date(timestampISO);