string-conversion

ValueError: could not convert string to float: '.'

a 夏天 提交于 2021-02-07 10:40:23
问题 I have a list of strings (CD_cent) like this: 2.374 2.559 1.204 and I want to multiply these numbers with a float number. For this I try to convert the list of strings to a list of floats for example with: CD_cent2=[float(x) for x in CD_cent] But I always get the error: ValueError: could not convert string to float: '.' . I guess this means, that it can't convert the dot to a float (?!) But how could I fix this? Why doesn't it recognize the dot? 回答1: You need to split each string as the

NumberFormatException while converting binary string to integer

守給你的承諾、 提交于 2021-01-27 22:01:00
问题 I am learning bit manipulation in java. So,I am converting binary string to integers bytes and short. Here is my program :- byte sByte,lByte; // 8 bit short sShort,lShort; // 16 bit int sInt,lInt; // 32 bit sByte= (byte)(int)Integer.valueOf("10000000", 2); //Smallest Byte lByte= (byte) ~sByte; sShort= (short)(int)Integer.valueOf("1000000000000000", 2); //Smallest Short lShort = (short) ~sShort; sInt = (int) (int)Integer.valueOf("10000000000000000000000000000000", 2); //Smallest Int lInt= (int

How to check if VARCHAR strings are (not) hexadecimal?

耗尽温柔 提交于 2020-12-10 13:28:29
问题 TL;DR How to test if string is hex when selecting rows? If I had a table with GUIDs where some of them are Base36 instead if hexadecimal: ID | GUID ===|================================= 1 | CAFEBABECAFED00DB16B00B515BADA55 2 | 0123456789ABCDEFGHIJKLMNOPQRSTUV 3 | DEADBEAF4D15EA5EDEFEC8EDFEE1DEAD I want to get all rows with GUIDs that are not exclusively hexadecimal. For a singleton, I could try CONVERT(VARBINARY(32),[GUID],2) and see if it fails, but I can’t to that in a query. If I could

How to check if VARCHAR strings are (not) hexadecimal?

混江龙づ霸主 提交于 2020-12-10 13:22:13
问题 TL;DR How to test if string is hex when selecting rows? If I had a table with GUIDs where some of them are Base36 instead if hexadecimal: ID | GUID ===|================================= 1 | CAFEBABECAFED00DB16B00B515BADA55 2 | 0123456789ABCDEFGHIJKLMNOPQRSTUV 3 | DEADBEAF4D15EA5EDEFEC8EDFEE1DEAD I want to get all rows with GUIDs that are not exclusively hexadecimal. For a singleton, I could try CONVERT(VARBINARY(32),[GUID],2) and see if it fails, but I can’t to that in a query. If I could

Convert Dash-Separated String to camelCase via C#

亡梦爱人 提交于 2020-08-20 09:12:38
问题 I have a large XML file that contain tag names that implement the dash-separated naming convention. How can I use C# to convert the tag names to the camel case naming convention? The rules are: 1. Convert all characters to lower case 2. Capitalize the first character after each dash 3. Remove all dashes Example Before Conversion <foo-bar> <a-b-c></a-b-c> </foo-bar> After Conversion <fooBar> <aBC></aBC> </fooBar> Here's a code example that works, but it's slow to process - I'm thinking that

convert string into datetime format in Javascript

微笑、不失礼 提交于 2020-03-22 07:54:15
问题 i have a string which, i want to compare with a javascript datetime object. how to convert string "1/1/1912" into datetime using JavaScript so that i can compare like if (EDateTime > ('1/1/1912')) {...} 回答1: You could do this simply with a split if you can guarantee the date format. var dateArray = '1/1/1912'.split("/"); new Date(dateArray[2], dateArray[1], dateArray[0]); 回答2: var dateArray = '2012-02-17 01:10:59'.split(' '); var year = dateArray[0].split('-'); var time = dateArray[1].split('

convert string into datetime format in Javascript

社会主义新天地 提交于 2020-03-22 07:53:38
问题 i have a string which, i want to compare with a javascript datetime object. how to convert string "1/1/1912" into datetime using JavaScript so that i can compare like if (EDateTime > ('1/1/1912')) {...} 回答1: You could do this simply with a split if you can guarantee the date format. var dateArray = '1/1/1912'.split("/"); new Date(dateArray[2], dateArray[1], dateArray[0]); 回答2: var dateArray = '2012-02-17 01:10:59'.split(' '); var year = dateArray[0].split('-'); var time = dateArray[1].split('

“Unrecognized token 'com': was expecting ('true', 'false' or 'null')”

╄→гoц情女王★ 提交于 2020-03-13 11:27:29
问题 I have converted this json to string to save in local database { "type": "file", "id": "b665ff0b-5f7b-4991-ae88-ac5054880223", "link": { "href": "https://s3-eu-west-com/87e9edff-e7bd-49ea-aa7a-8948cac29bc1/b665ff0b-5f7b-4991-ae88-ac5054880223.jpg" }, "file_name": "sony 431.jpg", "mime_type": "image/jpeg", "file_size": 66727, "public": true, "meta": { "dimensions": { "width": 1500, "height": 1500 }, "timestamps": { "created_at": "2018-01-22T11:07:35.527Z" } }, "links": { "current": "https:/

I have a string of octal escapes that I need to convert to Korean text - not sure how

孤街醉人 提交于 2020-01-06 15:25:14
问题 I found a similar question: Converting integers to UTF-8 (Korean) But I can't figure out how you would do this in .net c# Problem: I have a string from a database - "\354\202\254\354\232\251\354\236\220\354\203\201\354\204\270\354\240\225\353\263\264\354\236\205\353\240\245" That should translate to - 사용자상세정보입력 Any help would be greatly appreciated! 回答1: There are a number of steps involved in the conversion: Extract the individual octal numbers (such as 354 ) from the source string. Convert

How can I convert a REG_BINARY value from the registry into a string ? (vb.net)

*爱你&永不变心* 提交于 2020-01-02 10:03:14
问题 I have a registry value which is stored as a binary value (REG_BINARY) holding information about a filepath. The value is read out into an byte array. But how can I transform it into a readable string? I have read about system.text.encoding.ASCII.GetString(value) but this does not work. As far as I got to know the registry value is arbitrary binary data and not ASCII which is the reason for the method to produce useless data. Does anybody know how I can convert the data? Sample: (A piece of