본문 바로가기

Python10

json 파일 읽고 쓰기 # #파일쓰기 # #파일쓰기 def init_Bld_id(path, name, msg, idx): today = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') result = { "chat_detail" : [] } r = json.dumps(result) config_path = os.path.join(application_path, path) f = open(config_path + name , 'w') f.write(r) f.close() # config_path + file_name경로의 파일 있는지 확인해서 오픈하고 읽기 if ( os.path.isfile(config_path+file_name) ) : with open(config_path+f.. 2019. 3. 31.
[python/django] 장고 stop!!! 멈추기 아니 ... 서버 제대로 돌아가고 있나 봤는데 데이터는 안 나타나고 있고, 그래서 안돌아가나~ 해서 다시 돌리려고 런서버 했더니 에러가 뜨는게 아니겠음? $python3 manage.py runserver Error: That port is already in use. 이미 포트를 사용하고 있어?뭐 하나 쉽게 넘어 가는 법이 없다 정말... 원래 사용하는 :8000 포트를 지우는 명령어는아래와 같다고 함 $sudo lsof -t -i tcp:8000 | xargs kill -9sudo lsof -t -i tcp:8000 | xargs kill -9 근데 확인해보니 netstat -ntlp 안먹힘 runserver 죽이는(?) 명령어 사용 $sudo pkill -f runserver 성공 2019. 2. 11.
[python/lib] fake-agent로 웹 header의 agent값 임의로 만들기 # 설치pip install fake-useragent# 사용법은 매우 간단... from fake_useragent import UserAgent ua = UserAgent() ua_arr = [] ua_arr.append(ua.ie) ua_arr.append(ua.msie) ua_arr.append(ua['Internet Explorer']) ua_arr.append(ua.opera) ua_arr.append(ua.chrome) ua_arr.append(ua.google) ua_arr.append(ua['google chrome']) ua_arr.append(ua.firefox) ua_arr.append(ua.ff) ua_arr.append( ua.safari) for item in ua_arr: p.. 2019. 1. 10.
python 버그... pymysql.err.InterfaceError: (0, '') pymysql.err.InterfaceError: (0, '')... 자꾸 나타나​무슨 버그여 우선​가벼운 버그부터​ pymysql.err.InternalError: (1136, "Column count doesn't match value count at row 1")-> insert하려는데 컬럼개수랑 넣을 value랑 개수가 안맞다 라는 뜻​​​pymysql.err.InterfaceError: (0, '')-> conn 했으면 짝 맞춰서 close 똑바로 해줘라​​...넵​​​​​mysql하나 못다뤄서이게 무슨개발자야...새벽코딩 열정만 불태우지말고머리 팽글팽글 잘 돌아가는 때에 확 집중해서 버닝!!​컨디션 조절좀 잘하자 토닥토닥...ㅠ​체력안배도 기술의 하나인 듯​ 2019. 1. 9.