글쓰기
로그인
회원가입
#JAVA
아이포렝
· 4년전
질문
JAVA 코드를 PYTHON 으로 바꾸고 싶은데 도움 부탁드립니다 ㅠㅠ
안녕하세요. JAVA 코드를 PYTHON으로 바꿔서 쓰고싶은데 어떻게 바꿔야할지 감이 안와서 질문드립니다ㅠㅠ 이 코드를 PYTHON 으로 변경이가능할까요?ㅠㅠ 고수님들 부탁드립니다!ㅠㅠ public static boolean isRectangle(Point a, Point b, Point c, Point d){ double aby = a.y-b.y; double abx = a.x-b.x; double acy = a.y-c.y; double acx = a.x-c.x; double ady = a.y-d.y; double adx = a.x-d.x; double bcy = b.y-c.y; double bcx = b.x-c.x; double bdy = b.y-d.y; double bdx = b.x-d.x; double cdy = c.y-d.y; double cdx = c.x-d.x; return ((aby*aby) + (abx*abx)) == ((cdy*cdy) + (cdx*cdx)) && ((acy*acy) + (acx*acx)) == ((bdy*bdy) + (bdx*bdx)) && ((ady*ady) + (adx*adx) == (bcy*bcy) + (bcx*bcx)); } public static class Point{ double x; double y; public Point(double x,double y){ this.x = x; this.y = y; } }
#JAVA
#PYTHON
1.2K
0
jwkoh
· 6년전
질문
C# HttpContext에서 context 파라메터의 입력 형태가 어떻게 되나요?
코드 구현은 아래와 같습니다. 첫 줄에 ProcessRequest(HttpContext context) 구현 부분에 context 입력 형태를 확인하고 싶습니다. http://192.168.100.239/DocComplianceSDK/Download.ashx?token=a58af231-219a-482e-98ab-e178e7a1e853&fileName=GEN_CK_Administrative%20Document_0011_0.1.docx 위에 처럼 token, fileName을 만들어서 던져주는데도 코드 마지막 라인의 else 구문으로 진입되서 'No file token specified." 를 출력합니다. JAVA Client에서 C# Download.ashx로 요청을 보내는 구조입니다. 입력 형태를 어떻게 해야지 token과 fileName을 인식할까요? public void ProcessRequest(HttpContext context) { TransferFileInfo transferFileInfo; if (context.Items.Contains("token")) { string item = (string)context.Items["token"]; string str = (string)context.Items["fileName"]; DownloadRequest downloadRequest = FileDownloadPool.Instance[item]; if ((downloadRequest == null ? false : !downloadRequest.IsExpired())) { FileTransfer fileTransfer = new FileTransfer(); try { transferFileInfo = fileTransfer.ProcessDownloadRequest(downloadRequest); } catch (Exception exception1) { Exception exception = exception1; context.Response.StatusCode = 403; context.Response.StatusDescription = exception.Message; context.Response.ContentType = "text/xml"; context.Response.Write(this.CreateErrorResponse(context.Response.StatusDescription)); return; } try { context.Response.ContentType = transferFileInfo.ContentType; context.Response.AddHeader("content-disposition", string.Concat("attachment;filename=", (str == null ? transferFileInfo.FileName : str))); context.Response.WriteFile(transferFileInfo.Path); } catch (Exception exception3) { Exception exception2 = exception3; context.Response.StatusCode = 500; context.Response.StatusDescription = "Internal error"; context.Response.ContentType = "text/xml"; context.Response.Write(this.CreateErrorResponse(exception2.Message)); } } else { context.Response.StatusCode = 403; context.Response.StatusDescription = "The file token is not valid."; context.Response.ContentType = "text/xml"; context.Response.Write(this.CreateErrorResponse(context.Response.StatusDescription)); } } else { context.Response.StatusCode = 403; context.Response.StatusDescription = "No file token specified."; context.Response.ContentType = "text/xml"; context.Response.Write(this.CreateErrorResponse(context.Response.StatusDescription)); }
#C#
#JAVA
2.4K
2
1
0
kimho
·
2018-12-06
if (context.Items.Contains("token")) 위 부분을 아래와 같이 바꿔서 확인해보시기 바랍니다. if (context.Current.Items.Contains("token"))
더 보기