convert

Convert UPPERCASE string to sentence case in Python

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How does one convert an uppercase string to proper sentence-case? Example string: "OPERATOR FAIL TO PROPERLY REMOVE SOLID WASTE" Using titlecase(str) gives me: "Operator Fail to Properly Remove Solid Waste" What I need is: "Operator fail to properly remove solid waste" Is there an easy way to do this? 回答1: Let's use an even more appropriate function for this: string.capitalize >>> s="OPERATOR FAIL TO PROPERLY REMOVE SOLID WASTE" >>> s.capitalize() 'Operator fail to properly remove solid waste' 回答2: This will work for any sentence, or any

How do I convert an NSDictionary to a Swift Dictionary<String, NSObject>?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am rewriting an Objective-C class in Swift to get a feel for the language. In Objective-C my class included the following method: - (id) initWithCoder:(NSCoder *)aDecoder { return [self initWithActionName:[aDecoder decodeObjectOfClass:[NSString class] forKey:@"actionName"] payload:[aDecoder decodeObjectOfClass:[NSDictionary class] forKey:@"payload"] timestamp:[aDecoder decodeObjectOfClass:[NSDate class] forKey:@"timestamp"]]; } After some trial and error with the compiler, I managed to rewrite it like this: convenience init(aDecoder:

How to convert string array to int array in java

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an string array in java program like this String results[] = { "2", "1", "5", "1" }; I want to convert this to integer array as like this: int results[] = { 2, 1, 5, 1 }; And finally I want to find the summation of all the int elements of that array. 回答1: If you are using java 8 Try this : int[] array = Arrays.stream(resultsStr).mapToInt(Integer::parseInt).toArray(); 回答2: String resultsStr[] = {"2", "1", "5", "1"}; ArrayList intermediate = new ArrayList(); for(String str : resultsStr) { intermediate.add(Integer.parseInt(str, 10)); /

Java: convert birth data to days

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I really need some help with the specific assignment. The user inputs birth data (YYYY MM DD) and the program tells you how old you are in days : The outprint in console would be You are for example born 1981 11 06 You are 7068 days old. I've rewritten my code maybe 20 times without success, and any help would be so much appreciated, i'm kinda new so everything will be helpful! thanks a lot in advance, Sebastian. // the code ... :) EDITED .. I RE-WROTED THE CODE, since it didnt work anyhow i twisted and turned it so i changed it completly,

Convert str to numpy.ndarray

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a system to share video with opencv but I've got a problem. I've a server and a client but when I send informations to the server, the must be bytes. I send 2 things: ret, frame = cap.read() ret is a booland frame is the data video, a numpy.ndarray ret is not a problem but frame: I convert it in string and then in bytes: frame = str(frame).encode() connexion_avec_serveur.send(frame) I'd like now to convert again frame in a numpy.ndarray. 回答1: Your str(frame).encode() is wrong. If you print it to terminal, then you will find it

Convert XML String to Map and get the key & value pairs using Java

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have an XML String. I'm trying to convert that string into map so that I can get key & value. However its not able to convert. Here is my code String xmlString = "<?xml version=" 1.0 " encoding=" UTF - 8 "?><user> <kyc></kyc> <address></address> <resiFI></resiFI></user>" def convertStringToDocument = { xmlString -> DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance (); DocumentBuilder builder ; try { builder = factory . newDocumentBuilder (); org . w3c . dom . Document doc = builder . parse ( new InputSource (

Convert Image to binary stream

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There are two sides to my app, on one side I'm using C++ in order to read the frames from a camera using Pleora's EBUS SDK. When this stream is first received, before I convert the buffer to an image, I am able to read the stream 16 bits at a time in order to perform some calculations for each pixel, i.e. there exists a 16 bit chunk of data for each pixel. Now the second half is a Django web app where I am also presented this video output, this time via an ffmpeg, nginx, hls stream. When the user clicks on the video I want to be able to take

How to convert BNF to EBNF

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I convert this BNF to EBNF? ::= var ; ::= {; } ::= {, } : ::= { } ::= | | _ 回答1: EBNF or Extended Backus-Naur Form is ISO 14977:1996 , and is available in PDF from ISO for free * . It is not widely used by the computer language standards. There's also a paper that describes it, and that paper contains this table summarizing EBNF notation. The * operator is used with a preceding (unsigned) integer number; it does not seem to allow for variable numbers of repetitions ― such as 1-15 characters after an initial character to make

Java Convert this string to JSONArray [closed]

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting the following String response from a server: {"fid":"1272","uri":"http://someurl/services/file/1272"} I need to convert it into a JSONArray . Any help? By the way, I tried this and it does not work: String response=getResponseFromServer(); JSONArray array = new JSONArray(response); I get the error: org.json.JSONException: Value {"fid":"1272","uri":"http://someurl/services/file/1272"} of type org.json.JSONObject cannot be converted to JSONArray 回答1: If you're talking about using the JSON in java library, then since your input

ZXing convert Bitmap to BinaryBitmap

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using OpenCV and Zxing, and I'd like to add 2d code scanning. I have a few types of images that I could send. Probably the best is Bitmat (the other option is OpenCV Mat). It looks like you used to be able to convert like this: Bitmap frame = //this is the frame coming in LuminanceSource source = new RGBLuminanceSource(frame); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); //then I can use reader.decode(bitmap) to decode the BinaryBitmap However, RGBLuminaceSource looks like it no longer takes a bitmap as an input.