convert

How do I convert an integer to a javascript color?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an integer which I need to convert to a color in javascript. I am using an MVC model and am trying to replicate a model in a software for a web interface. I have the color in integer format from the database. It needs to be converted to a color in javascript. For example: integers like -12525360, -5952982 I have the code like this : items[x].barStyle = "stroke: Black; fill = Red"; So instead of giving the fill:Red, I need to give it the exact color corresponding to the integer value. This is the code I have written in C#. I need the

Convert word to pdf using free third party dll

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to convert word document to pdf. i found lots of solution using office dll. But i want a solution using free third party dll because in office dll there must be office installed. so on my server there is'n office installed. Is there any free third party dll??? 回答1: EDIT: Oops, looks like you do have to have office installed. One of the comments in the second link mentions using OpenXmlPowerTools.HtmlConvertor and iTextSharp to convert the document into HTML, and then going to a PDF. Good luck with that! If you're using .docx files,

Convert Html and Set text to Textview

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to convert a html String and set it to a TextView but I couldn't do it exactly. Here is my String, "Hello, %1$s! You have <b>%2$d new messages</b>" I am using textview.setText(Html.fromHtml(myString)); which produces me an output with Html Tags instead of plain text. Can anyone help me with this? Any help is much appreciated. Thanks 回答1: Try use this version of setText and use SPANNABLE buffer type 回答2: Refer to this question . try: textView.setText(Html.fromHtml(myString), TextView.BufferType.SPANNABLE); 回答3: This may be helpful

How can I convert RGB to CMYK and vice versa in python?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If I had a RGB decimal such as 255, 165, 0 , what could I do to convert this to CMYK? For example: >>> red, green, blue = 255, 165, 0 >>> rgb_to_cmyk(red, green, blue) (0, 35, 100, 0) 回答1: Here's a Python port of a Javascript implementation . cmyk_scale = 100 def rgb_to_cmyk(r,g,b): if (r == 0) and (g == 0) and (b == 0): # black return 0, 0, 0, cmyk_scale # rgb [0,255] -> cmy [0,1] c = 1 - r / 255. m = 1 - g / 255. y = 1 - b / 255. # extract out k [0,1] min_cmy = min(c, m, y) c = (c - min_cmy) / (1 - min_cmy) m = (m - min_cmy) / (1 - min_cmy

how to convert raw images to png in python?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a folder containing over 200 raw images, i want to convert all of them to png or any other format, In C it's pretty easy but in python i don't know how it's done I found this snippet #import struct import numpy, array, PIL, Image from struct import * #declarations arr1D = array.array('H') #H is unsigned short #------------------------------------ #read 16 bit unsigned raw depth image #------------------------------------ w = 640 h = 480 fid = open('/home/salman/salman/NiSimpleRead_salman/data/200.raw') #fid = open('/home/salman/test

PHP Datetime fail to convert negative ISO8601 date

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Converting a negative date with DateTime get me false Test code var_dump ( \DateTime :: createFromFormat ( \DateTime :: ISO8601 , '-0001-11-30T00:00:00+0100' )); Result boolean false Expected result object ( DateTime )[ 5 ] public 'date' => string '-0001-11-30 00:00:00' ( length = 20 ) public 'timezone_type' => int 1 public 'timezone' => string '+01:00' ( length = 6 ) (or something similar) P.S. The negative date string was created with $d->format(\DateTime::ISO8601); PHP version PHP 5.4.28 回答1: According to manual of Format public

Convert a python dataframe with multiple rows into one row using python pandas?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Having the following dataframe, df = pd.DataFrame({'device_id' : ['0','0','1','1','2','2'], 'p_food' : [0.2,0.1,0.3,0.5,0.1,0.7], 'p_phone' : [0.8,0.9,0.7,0.5,0.9,0.3] }) print(df) output: device_id p_food p_phone 0 0 0.2 0.8 1 0 0.1 0.9 2 1 0.3 0.7 3 1 0.5 0.5 4 2 0.1 0.9 5 2 0.7 0.3 How to achieve this transformation? df2 = pd.DataFrame({'device_id' : ['0','1','2'], 'p_food_1' : [0.2,0.3,0.1], 'p_food_2' : [0.1,0.5,0.7], 'p_phone_1' : [0.8,0.7,0.9], 'p_phone_2' : [0.9,0.5,0.3] }) print(df2) Output: device_id p_food_1 p_food_2 p_phone_1 p

Convert String value format of YYYYMMDDHHMMSS to C# DateTime

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a need to convert a string value in the form "YYYYMMDDHHMMSS" to a DateTime. But not sure on how, may be a DateTime.Tryparse can be used to make this happen. Or is there any other way to do it. I can do this using some string operations to take "YYYYMMDD" alone, convert to a datetime and then add HH, MM, SS separately to that DateTime. But is there any DateTime.TryParse() methods that I can use in one line to convert a "YYYYMMDDHHMMSS" format string value to a DateTime value? 回答1: Define your own parse format string to use. string

How can I convert TBytes to RawByteString?

匿名 (未验证) 提交于 2019-12-03 03:02:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the best way to convert an array of bytes declared as TBytes to a RawByteString in Delphi 2009? This code actually works, maybe there is a faster way (without loop): function Convert(Bytes: TBytes): RawByteString; var I: Integer; begin SetLength(Result, Length(Bytes)); for I := 0 to ABytes - 1 do Result[I + 1] := AnsiChar(Bytes[I]); end; 回答1: You could consider using move (untested) function Convert(const Bytes: TBytes): RawByteString; begin SetLength(Result, Length(Bytes)); Move(Bytes[0], Result[1], Length(Bytes)) end; And use

How to convert BeautifulSoup.ResultSet to string

匿名 (未验证) 提交于 2019-12-03 03:02:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So I parsed a html page with .findAll (BeautifulSoup) to variable named result . If I type result in Python shell then press Enter, I see normal text as expected, but as I wanted to postprocess this result as string object, I noticed that str(result) returns garbage, like this sample: \xd1\x87\xd0\xb8\xd0\xbb\xd0\xbd\xd0\xb8\xd1\x86\xd0\xb0</a><br />\n<hr />\n</div> Html page source is utf-8 encoded How can I handle this? Code is basically this, in case it matters: from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(urllib.open(url)