프로그래밍 (363) 썸네일형 리스트형 [Python초보] ValueError: invalid literal for int() with base 10: '' invalid literal for int() with base 10: '' 10진수 int() 로 변환할 수 없는 문자열: '' 이라는 뜻입니다. 한번 이 에러를 만들어 봅시다. >>> num = int("1000") >>> num 1000 "1000" 이라는 문자열을 숫자형으로 변환하여 num 이란 변수에 넣는 코드입니다. "1000"이라는 문자열은 정수를 나타내는 문자열이기 때문에, 문제없이 변환됩니다. >>> s = "abc" >>> num = int(s) Traceback (most recent call last): File "", line 1, in num = int(s) ValueError: invalid literal for int() with base 10: 'abc' "abc" 라는 문.. [SWIFT] dump() 함수 출력을 문자열로 바꾸는 방법 dump 함수는 클래스 인스턴스의 내부 속성까지 간단히 출력해 주기 때문에 디버깅시에 편리하다. 그런데, 출력 내용을 문자열로 저장하여, stdout, stderr 가 아닌 곳으로도 출력/저장하고 싶었다. 스택오버플로우에 간단한 답변이 있었다. https://stackoverflow.com/a/42094841/100093 let myClass = MyClass() var myClassDumped = String() dump(myClass, to: &myClassDumped) https://github.com/apple/swift/blob/master/stdlib/public/core/OutputStream.swift 위 링크를 인용하고 있는데, 직접 영문설명을 읽어보는 게 좋겠지만, 요약하면, print.. [Python] 십진수소수 이진수로 변환하기 십진수 정수를 이진수로 변환하는 것은 파이썬이 기본으로 제공하는 bin 함수를 사용하면 된다. 소수점 이하 자릿수를 포함한 십진수를 이진수로 표현하는 함수를 만들어 보았다. 입력을 float 으로 변환하면, 부동소수점 오류로 정확한 계산이 불가능하다. 분수를 다룰 수 있는 fractions 모듈을 이용하여 정확하게 소수점 아래까지 구할 수 있다. 순환마디까지 구할 수 있는데, 일단 무시하고 30자리까지 구하는 걸 구현했다. from fractions import Fraction def conv2bin(s): x = Fraction(s) x1 = x//1 x2 = x - x1 digits = [] tail = "..." for _ in range(30): if x2 == 0: tail = "" break .. [XPC] 새로운 타겟에서 xpc service 사용하기 Error Domain=NSCocoaErrorDomain Code=4099 xpc service 를 만들었다. xpc service 를 사용해야 하는 어플리케이션 타겟을 만들어, 기존에 만든 xpc service 의 함수를 호출하려 했다. 그런데, 함수호출을 했는데도, 서비스와의 연결이 실패했다는 에러가 발생하였다. Received error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.xxxx.xxxxxpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.xxxx.xxxxxpc was inval.. communcation over XPC is asynchronous https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html Designing an Interface The NSXPCConnection API takes advantage of Objective-C protocols to define the programmatic interface between the calling application and the service. Any instance method that you want to call from the opposite side of a connection must be explicitl.. [Swift|번역] Process waitUntilExit 은 비동기 completion handler 와 같이 쓰지 않는다. https://stackoverflow.com/a/49541564 동기함수인 waitUntilExit() 은 비동기적 completion handler 와는 같이쓰기 어렵다. 비동기 completion handler 를 사용한다면, exit 을 기다리는 건 의미없는 일이다. --- pipe의 fileHandleForReading 을 클로져에서 사용하기 때문에 double free 에러가 발생하는 것일 수 있다. stdout 을 동기적으로 읽으라. Flutter Warning: Operand of null-aware operation '!' hastype 'SchedulerBinding' which excludes null. 올해 초에 만들었던 플러터 프로젝트를 다시 빌드하다 보니 다음과 같은 경고메시지가 떴다. 동작은 했지만, 우찌 없앨지 고민했다. /D:/DEV_FLUTTER/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_math_fork-0.5.0/lib/src/widgets/selectable.dart:459:24: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null. - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/D:/DEV_FLUTTER/flutter/packages/.. powershell 이 시스템에서 스크립트를 실행할 수 없으므로 Microsoft.PowerShell_profile.ps1 파일을 로드할 수 없습니다. vscode 나 일반 cmd 창, terminal 등을 열 때, 빨간색으로 다음과 같은 에러메시지가 뜨는 경우를 자주 만난다. powershell 경고문구인데, powershell 을 본격적으로 사용하지 않으니 그냥 지나치면 되지만, 경고문구가 거슬린다. 해결방법을 포스팅해 놓는다. 에러문구는 다음과 같다. . : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\Me\Documents\WindowsPowerShell\Microsoft.PowerShell_profil e.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies(https://go.microsoft.com/fwlink/?LinkID=135170) 를 참조하십시오. 위치 줄:1 문자:3 + ... 이전 1 2 3 4 5 6 7 ··· 46 다음