프로그램 작성

전문가 및 열성적 프로그래머를위한 Q & A

5
matplotlib의 날짜 눈금 및 회전
matplotlib에서 날짜 눈금을 회전시키는 데 문제가 있습니다. 작은 샘플 프로그램은 다음과 같습니다. 마지막에 진드기를 회전하려고하면 진드기가 회전하지 않습니다. 주석 'crashes'에 표시된대로 눈금을 회전하려고하면 matplot lib가 충돌합니다. 이것은 x- 값이 날짜 인 경우에만 발생합니다. 내가 변수로 대체하는 경우 dates변수와 t의 통화에서을 avail_plot의 xticks(rotation=70)호출은 잘 내부를 작동합니다 avail_plot. 어떤 아이디어? import numpy …
175 python  matplotlib 


4
Node.js에서 process.env.PORT은 (는) 무엇 이죠?
process.env.PORT || 3000Node.js에서 무엇을 사용합니까? 나는 이것을 어딘가에서 보았다 : app.set('port', process.env.PORT || 3000); 3000청취 포트 로 설정하는 데 사용하는 경우 대신 사용할 수 있습니까? app.listen(3000); 왜 그렇지 않습니까?
175 node.js  express  port 

4
모의 메소드에 대한 연속 호출 주장
모의에게 유용한 assert_called_with()방법이 있습니다. 그러나 내가 이해 하는 한 메소드에 대한 마지막 호출 만 확인합니다 . 매번 다른 매개 변수를 사용하여 mocked 메서드를 3 번 ​​연속적으로 호출하는 코드가있는 경우 특정 매개 변수를 사용 하여이 3 호출을 어설 션하려면 어떻게해야합니까?
175 python  mocking 

6
pytest에서 콘솔로 인쇄하는 방법은 무엇입니까?
와 함께 TDD (테스트 중심 개발)를 사용하려고합니다 pytest. 내가 사용할 때 콘솔에 pytest없습니다 .printprint 나는 pytest my_tests.py그것을 실행하는 데 사용 하고 있습니다. 는 documentation: 그것은 기본적으로 작동한다고 말할 것 http://pytest.org/latest/capture.html 그러나: import myapplication as tum class TestBlogger: @classmethod def setup_class(self): self.user = "alice" self.b = tum.Blogger(self.user) print "This should be …

3
팬더 DataFrame의 마지막 N 행을 얻는 방법은 무엇입니까?
팬더 데이터 프레임이 df1있고 df2(df1은 바닐라 데이터 프레임이고 df2는 'STK_ID'& 'RPT_Date'에 의해 색인됩니다) : >>> df1 STK_ID RPT_Date TClose sales discount 0 000568 20060331 3.69 5.975 NaN 1 000568 20060630 9.14 10.143 NaN 2 000568 20060930 9.49 13.854 NaN 3 000568 20061231 15.84 19.262 NaN 4 000568 20070331 17.00 6.803 …
175 python  pandas  dataframe 

1
Django 쿼리 세트에서 필터 이하를 수행하는 방법은 무엇입니까?
프로파일이라는 각 사용자 프로파일의 사용자 정의 필드로 사용자를 필터링하려고합니다. 이 필드는 레벨이라고하며 0-3 사이의 정수입니다. equals를 사용하여 필터링하면 예상대로 선택한 수준의 사용자 목록이 표시됩니다. user_list = User.objects.filter(userprofile__level = 0) 미만을 사용하여 필터링하려고 할 때 : user_list = User.objects.filter(userprofile__level < 3) 오류가 발생합니다. 글로벌 이름 'userprofile__level'이 정의되지 않았습니다 <또는>로 필터링하는 방법이 …

11
스위프트 범위에서 NSRange?
문제 : Range를 사용하는 Swift String을 사용하는 동안 NSAttributedString이 NSRange를 사용합니다. let text = "Long paragraph saying something goes here!" let textRange = text.startIndex..<text.endIndex let attributedString = NSMutableAttributedString(string: text) text.enumerateSubstringsInRange(textRange, options: NSStringEnumerationOptions.ByWords, { (substring, substringRange, enclosingRange, stop) -> () in if (substring == "saying") { attributedString.addAttribute(NSForegroundColorAttributeName, value: NSColor.redColor(), range: substringRange) …
175 ios  macos  swift  nsrange 

8
TypeError : Router.use ()에는 미들웨어 함수가 필요하지만 객체가 있습니다.
새 Express Express 버전에서 약간의 미들웨어 변경이 있었으며이 문제에 대한 다른 게시물 중 일부에서 내 코드에서 일부 변경을 수행했지만 아무 것도 고칠 수 없습니다. 사전에 작동했지만 변경 내용을 기억할 수 없습니다. throw new TypeError('Router.use() requires middleware function but got a ^ TypeError: Router.use() requires middleware function but got a Object …


7
dplyr tbl 열을 벡터로 추출
데이터베이스 백엔드가있는 tbl에서 dplyr tbl의 한 열을 벡터로 얻는 더 간결한 방법이 있습니까? require(dplyr) db <- src_sqlite(tempfile(), create = TRUE) iris2 <- copy_to(db, iris) iris2$Species # NULL 너무 쉬웠을 겁니다 collect(select(iris2, Species))[, 1] # [1] "setosa" "setosa" "setosa" "setosa" etc. 그러나 약간 서투른 것 같습니다.

4
constexpr에서 std :: string을 사용할 수 있습니까?
C ++ 11, Ubuntu 14.04, GCC 기본 툴체인 사용 . 이 코드는 실패합니다 : constexpr std::string constString = "constString"; 오류 : constexpr 변수 'constString'의 'const string {aka const std :: basic_string}'유형은 리터럴이 아닙니다 ... 왜냐하면 'std :: basic_string'은 사소한 소멸자를 갖지 않기 때문입니다. 그것은 사용할 수 있습니다 std::stringA의 constexpr? (분명히 …

2
TypeError : 해시 할 수없는 유형 : 'dict'
이 코드는 unhashable type: dict누군가에게 해결책이 무엇인지 설명 할 수 있는 오류 를 제공합니다. negids = movie_reviews.fileids('neg') def word_feats(words): return dict([(word, True) for word in words]) negfeats = [(word_feats(movie_reviews.words(fileids=[f])), 'neg') for f in negids] stopset = set(stopwords.words('english')) def stopword_filtered_word_feats(words): return dict([(word, True) for word in words if word not in …
175 python 

18
라 라벨 PHP 명령을 찾을 수 없습니다
문제없이 작곡가를 사용하여 Laravel을 설치했지만 터미널에서 " laravel " 을 실행하려고 할 때 다음과 같은 일반적인 오류가 발생합니다. -bash : laravel : 명령을 찾을 수 없습니다 공식 사이트의 문서를 읽으면 다음을 수행해야합니다. 터미널에서 laravel 명령 을 실행할 때 laravel 실행 파일을 찾을 수 있도록 ~ / .composer / vendor / …
175 php  bash  laravel 


당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.