본문 바로가기

분류 전체보기492

파이썬으로 첫번째 띄어쓰기 전 문장 가져오기 파이썬으로 첫번째 띄어쓰기 전 문장 가져오기  주어진 문자열에서 첫 번째 "\n"이 나오기 전까지의 문자열을 가져오면됩니다. Python에서 split 메서드를 사용할 수 있습니다. 다음은 그 예시 코드입니다.# 예시 문자열text = "첫번째 줄\n두번째 줄\n세번째 줄"# 첫 번째 \n 이전까지의 문자열 추출first_line = text.split('\n')[0]print(first_line) 2024. 8. 11.
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks... To disable this warning, you can either: huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks... To disable this warning, you can either: 이 경고는 Huggingface tokenizers 라이브러리에서 병렬 처리가 이미 사용된 후 프로세스가 포크될 때 발생합니다. 이는 잠재적인 데드락을 방지하기 위한 안전 조치입니다. 이 경고를 비활성화하려면 아래 코드를 추가해 주세요 ! import osos.environ["TOKENIZERS_PARALLELISM"] = "false" 2024. 8. 1.
TypeError: Object of type ndarray is not JSON serializable TypeError: Object of type ndarray is not JSON serializable 1. 오류설명- 파이썬 딕셔너리를 json파일로 저장할때, array이가 포함되어 있다면 발생하는 오류 입니다.import jsonimport numpy as npy = np.array([3,4])dict = { "name" : "John", "array" : y}with open("temp.json", 'w') as f: json.dump(dict, f) TypeError: Object of type ndarray is not JSON serializable 2. 해결방법-  array를 list로 변경하면 문제없이 저장 됩니다.-  tolist() 메서드를 활용하여 array를 리.. 2024. 7. 31.
vim 여러줄 주석 처리 vim 여러줄 주석 처리1. 원하는 줄을 v를 hjkl 방향키를 이용하여 블록을 선택합니다. 2.  shift + :  를 통해 명령라인 모드에 진입합니다. 여러 줄을 선택 후 명령라인모드에 진입하면, 아래 그림과 같이  ' 을 포함한 명령라인이 나타납니다. 3.  norm i# 을 입력하면, 선택된 줄 제일 앞줄에 #이 입력 됩니다. 4. 주석을 지우려면 다시 원하는 줄을 선택하고   shift + :  로 명령모드 진입 후,   norm 1x  을 입력하여 주석을 지울 수 있습니다. 2024. 7. 29.
ProgrammingError: Cannot operate on a closed cursor. ProgrammingError: Cannot operate on a closed cursor.아래 코드와 같이  conn.cursor()  사용하여 cursor 객체를 살리고 코드를 도리면 에러가 사라지네요.import sqlite3conn = sqlite3.connect('example.db')# cursor object 재작동cursor = conn.cursor() 2024. 7. 28.
ERROR: Could not find a version that satisfies the requirement sqlite3 (from versions: none) ERROR: No matching distribution found for sqlite3 ERROR: Could not find a version that satisfies the requirement sqlite3 (from versions: none) ERROR: No matching distribution found for sqlite3 sqlite 3 설치과정이에 위와 같은 에러가 뜨네요 ㅠ저는 conda 가상환경을 주로 사용하기 때문에 pip install 말고 conda install 방식을 사용하여 해결하였습니다. 아래 코드를 사용하여 에러가 발생하였다면, pip install sqlite3 conda install을 아래 코드와 같이 사용해보세요conda install blaze::sqlite3 2024. 7. 28.