Python
taka-say.hateblo.jp ä¸è¨è¨äºã®ç¶ãã§ãã 復ç¿ã¯é¢åã ãå½¹ã«ç«ã¤ ååã®è¨äºã§ã¯ãã¬ããã¼ã®é¡ã¨ããã§ãªããã®ã®äºå¤åé¡ãè¡ãã¢ãã«ãä½æããå®éã«åç»ã¸ã®é©ç¨ã試ã¿ã¾ããã æ®å¿µãªããä¸æãããã¾ããã§ããã 詳細ã¯åç·¨ãã©ããã å¿èã¯è¾ãâ¦
ã¬ããã¼è¦è´ãæ¯é±ã®æ¥½ãã¿ã«ãã¦ããæ¹ãå¤ãã®ã§ã¯ãªãã§ããããã ããããç§ããã®ä¸äººã§ãã ç¾ä»£ç¤¾ä¼ã®èæ³¢ã«æã¾ãã¦ã¯å¿ãèãæ¥ã ã ç¼ç±å°çã®ç æ¼ ã«ä¸ããããä¸ç¸·ã®æã¿ããªã¢ã·ã¹ã ç§ã«ã¨ã£ã¦ãæãã³ã¹ãè¸ãã¬ããã¼ã¨ã¯ãã®ãããªåå¨ã¨â¦
ModelViewSetãªããã使ç¨ãã¦ããã¨ãããããã®ã¢ã¯ã·ã§ã³æ¯ã«serializerãå¤æ´ããããã¨ãå¤ã ããã¨æãã¾ãã æ¥æ¬èªæ å ±ãå°ãªãã¦ãã¹ããã©ã¯ãã£ã¹ãªã®ãã©ããã¯çãããã§ãããã¯ã©ã¹ãã¼ã¹viewã®ä¸ã§serializerãå¤æ´ããæ¹æ³ãã¨ããããã¡ã¢â¦
å¤æ°ã®ä¸èº«ã®ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã¯èªåçã«è§£éããã¦ãã¾ãã¾ãã ä¾ãã°ä¸è¨ã®ããã«ãªãã¾ãã >>> s = '1\n2\n3\n' >>> print(s) 1 2 3 å¤æ°ã«å¯¾ãã¦Pythonã®raw stringè¨æ³ã¯ä½¿ç¨ã§ãã¾ããã ããã§reprã使ç¨ããã¨ã >>> print(repr(s)) '1\n2\n3\â¦
æ¥æ¬èªWikipediaã®ãã³ããã¼ã¿ä¸ã®æ¬æãå©ç¨ãããã ãã ãåç´ã«ãã¼ã¹ããã ãã§ã¯Wikiè¨æ³ã®è¨å·çãéªéã§ããã ã¨ããããã§Wikipedia Extractorãå©ç¨ãã¦æ¬æã ãããã¹ãã¨ãã¦æ½åºãã¾ãã Wikipedia Extractorã®ä»ã«ããã¼ã¹ããããã®ã©ã¤ãâ¦
å®è·µæ©æ¢°å¦ç¿ã·ã¹ãã ã§æãåããã¦ããã¨ãããimport matplotlib.pyplotå®è¡æã«ä¸è¨ã®ãããªã¨ã©ã¼ã«ééãããã解決çã®ã¡ã¢ã RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly â¦
ãPython3ã大æåå°æåã«é¢ãããæç« ä¸ã«æå®ããã¯ã¼ããããã調ã¹ã
Pythonã®æ£è¦è¡¨ç¾ã使ãã°ç°¡åã«èª¿ã¹ããã¨ãã§ãã¾ãã re.searchã®ç¬¬ä¸å¼æ°ã«re.IGNORECASEãæå®ãã¦ãããã°OKã import re word = 'Python' description = 'pythonãæãã' if re.search(word, description, re.IGNORECASE): # å®è¡ãããå¦ç PYthonâ¦
大éãã¤å¤§ããxlsxãã¡ã¤ã«ãååã®ã¾ã¾csvã«å¤æãããã£ãã®ã§ãããè¯ãæ¹æ³ãã½ãããè¦ã¤ãããªãã£ãããèªåã§è¡ãã¾ããã å¤åãã£ã¨ã¹ãã¼ããªããæ¹ããããã ãããªã¨æãã¤ã¤ãã¨ããããã¡ã¢ã ç°å¢ Mac OSX Yosemite zsh Python3 æºå pipã§â¦
æ¥æ¬èªWikipediaãªã³ããã¸ã¼ ä¸è¨æ¥æ¬èªWikipediaãªã³ããã¸ã¼ã®ãã¼ã¿ãPythonããå¼ããåãããã£ãã®ã§rdflibã使ãã¾ããã æçµçã«ã¯ãã¡ã¤ã«ãµã¤ãºã大ãããã¦ç´æ¥çãªä½¿ç¨ãæ念ããã®ã§ããâ¦â¦ã ãã¼ã¿ã®æ¤ç´¢é¨åã®ã¿åå¿é²çã«è»½ãã¡ã¢ã rdfã¸â¦
PyMySQL3ã使ã£ã¦DBå ã®ãã¼ã¿åå¾ãããã¨ãããvarcharåã«è¨å®ãããã«ã©ã ã®ãã¼ã¿ãbytesåã§è¿ã£ã¦ãã¦ãã¾ãåé¡ã«ééã å¾ã ã®ããã¡ã¢ã ç°å¢ Python 3.4.3 MySQL 5.6 PyMySQL3 解決ç PyMySQL3ã¸ã®æ¥ç¶ã¨ã¯ã¨ãªã¯ä»¥ä¸ã®ãããªå¹³å¡ãªãã®ã§ããã â¦
ç°å¢ Python 3.4.3 æ¹æ³ xml.sax.saxutilsã¢ã¸ã¥ã¼ã«ã®unescapeã¡ã½ããã使ãã°OKã from xml.sax.saxutils import unescape text = '& < >' print(unescape(text)) # => '& < >' 第äºå¼æ°ã«dictãä¸ããã¨ãç¬èªè¾æ¸ã®å®ç¾©ãå¯è½ã¨ã®ãã¨ã fromâ¦
ã¾ãå¼ã£ããããããªã®ã§ã¡ã¢ã ç°å¢ Python 3.4.3 sqlite3 解決ç executeã¡ã½ããã§SQLãå®è¡ãããã¨ããã¨ããã sqlite3.ProgrammingError: Incorrect number of bindings supplied. ã¨æããã¦ãã¾ãã¾ããã åå ã¯åç´ã§ãexecuteã¡ã½ããã®ç¬¬äºå¼â¦
対話åã·ã§ã«ãèµ·åãä¸è¨ãå®è¡ã >>> import site; site.getsitepackages() ã¯ã³ã©ã¤ãã¼ã§å®ã
Twitterããåå¾ãããã¼ã¿ãMeCabã§å¦çããFlaskãç¨ããWebã¢ããªã±ã¼ã·ã§ã³ä¸ã§è¡¨ç¤ºãããã¨ããã¨ãããä¸è¨ã®ãããªã¨ã©ã¼ãåºç¾ã builtins.UnicodeDecodeError UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 0: invalid stâ¦
é常Bottleã使ç¨ããå ´åã¯ã使ç¨ãããã³ãã¬ã¼ãã«ä½µãã¦å¿ è¦ãªã¡ã½ããããã³ã¬ã¼ã¿ãã¤ã³ãã¼ããã¦ç¨ãããã¨ã§ãviewãã³ãã¬ã¼ãã®æç»ãé常ã«ç°¡åã«è¡ããã¨ãåºæ¥ã¾ãã ä¾ãã°ãJinja2ãã³ãã¬ã¼ãã使ç¨ããã¡ã½ããã§viewãã³ãã¬ã¼ãã®æç»ãâ¦
Noneã£ã¦ãªãã ãã¨åº¦ã æãããã®ã§ã¡ã¢ã Jinja2ã§ã¯Pythonã®True,False,Noneã¯å°æåã§è¡¨è¨ãããã # à {% if some_func() is None %} # ⯠{% if some_func() is none %} ããå æ¸ã«ãã£ã¦ãã¨çµæ§é£ããâ¦â¦ã åè Jinja2 ããã¥ã¡ã³ãæ¥æ¬èªè¨³
pythonã³ã¼ããæ¸ãã¦ããéã«ãreturnãæ¸ãã¦ããªãï¼è¿ãå¤ã®æå®ããªãï¼é¢æ°ãä½ãè¿ãã¦ããã®ããæ°ã«ãªã£ãããã¡ã¢ã çµæããããã¨Noneãè¿ãã¦ããã def foo(): pass foo() is None # True æ示çã«returnãæ¸ããå ´åãåæ§ã«Noneãè¿ãã¦ããâ¦
Bottleã§äºãè¨å®ãããviewã®templateæ¢ç´¢ç¨ãã¹ã¯['./', './views/']ã®ã¿ã èªåã§ã«ã¹ã¿ãã¤ãºãããã£ãã®ã§è¿½å ã é©å½ãªå ´æã§ã TEMPLATE_PATH.insert(0, './some/path/') ãããã°OKã åè Template Search-Path Workaround
ç°å¢ Python 3.4.3 åé¡ Pythonã§ãã¥ã¼çãªå®è£ ããããã£ããã import Queue q = Queue.Queue() ã¨ããã¨ãã ImportError: No module named 'Queue' ã¨è¨ããææ²ã 解決 å ¬å¼ããã¥ã¡ã³ãã«ããã¨ãã©ããPython3ã§ã¯æ§æ¥ã®Queueã¢ã¸ã¥ã¼ã«ã®ååãqueuâ¦
åã ãã使ã£ã¦ã¿ããã¨ã¯æã£ã¦ããã®ã§ããããã®åº¦å°ãçæ´»ã«éãåºæ¥ããã諸ã ã®ããã°ã©ãã³ã°ç³»æ¸ç±ã¨ä¸ç·ã«å ¥éæ¸ãè³¼å ¥ãã¦æ¥ã¾ãããPythonãã¥ã¼ããªã¢ã« 第2çä½è : Guido van Rossum,鴨澤ç夫åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã¸ã£ãã³çºå£²æ¥: 2010/â¦