Python
http://d.hatena.ne.jp/leetmikeal/20140214/1392375216ååã®è¨äºã§ãå¤æ°ã®åãisinstanceé¢æ°ã使ç¨ãã¦ãã§ãã¯ã§ããã¨æ¸ãã¾ããããã®ã¹ã¯ãªãããå®è¡ãã¾ãã #!/usr/bin/python # -*- coding:utf-8 -*- def func_inst(): return "func inst" if __â¦
â»Python 2.7Pythonã§åã調ã¹ãæ¹æ³ã¯ç°¡åã§ãisinstanceã¨ããçµã¿è¾¼ã¿é¢æ°ã使ç¨ãã¾ããlistãã©ããã調ã¹ãéã¯ã if isinstance([], list): print "this is list type." if isinstance(1, int): print "this is integer type." ã¨ãããµãã«ãã¾ããliâ¦
ä¹ ã ã®ã¡ã¢ã§ããPythonã§subprocessãç¨ãã¦ã³ãã³ããå®è¡ããéã®æ¨æºåºåãããªã¢ã«ã¿ã¤ã ã§åå¾ãã¦ãã¦è¡¨ç¤ºãããµã³ãã«ããã°ã©ã ã§ããè¯ãè¦ããããµã³ãã«ããã°ã©ã ã ã¨ããã¡ãã¨ã³ãã³ããçµäºãã¦ããã®åºåãå¤æ°ã«åå¾ããæ¹æ³ããè¼ã£ã¦ãªâ¦
Mac Book Airã«pythonã®2.7.4ãã½ã¼ã¹ã³ã¼ãããã¤ã³ã¹ãã¼ã«ãã¦ã¿ã¾ãããå ¨ãLinuxã¨åãã§ãã cd ~ mkdir -p apps/src cd apps/src curl -O http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz tar xzvf Python-2.7.4.tgz cd Python-2.7.4 ./conâ¦
ã¢ã¸ã¥ã¼ã«ï¼ãã©ã°ã¤ã³ãããã±ã¼ã¸ã¨ãããã®ããªï¼ãå©ç¨ããpythonã¹ã¯ãªãããé å¸ããéã«ããããå®è¡ããåã«ããã±ã¼ã¸ã使ãããã©ããããã§ãã¯ãã¦ãããã¨è¦ªåã§ãããpythonèªä½ãåºãã¨ã©ã¼ã§ãåãã人ã«ã¯ãããã®ã§ããããã¡ãã¨ããã¹â¦
å¤ãpythonãã¤ã³ã¹ãã¼ã«ããå¿ è¦ããã£ãã®ã§ã2.6ãã¤ã³ã¹ãã¼ã«ãã¾ãããèªåã®ãã¼ã ãã©ã«ãã«ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãããã¦ã³ãã¼ãå ï¼Python 2.6.8 Release | Python.org mkdir -p ~/apps/src cd ~/apps/src wget http://www.python.org/ftp/pythoâ¦
pythonã®ãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ããéã«ã¾ãå¿ è¦ã¨ãªãsetuptoolsãã¤ã³ã¹ãã¼ã«ããéã«ã¨ã©ã¼ãåºã¦ãã¾ããé²ãã¾ããã§ãããsetuptools 36.5.0 : Python Package Index [FAQ]Pythonã®Distributeã®ã¤ã³ã¹ãã¼ã«ã«å¤±æãã - ååä¼ç¤¾ãã£ã¼ã«ãã¯ã¼ã¯â¦
ãããã¯ã¼ã¯ããé®æããã¦ãããã·ã³ã«pythonã®æ§æãã§ãã¯ãã©ã°ã¤ã³pep8ãå ¥ãããã¨ããã¨ãããããããªä¾åã©ã¤ãã©ãªã1ã¤ãã¤è½ã¨ããã¡ã«ãªã£ã¦ãã¾ã£ãã®ã§ãä»å¾ã®ããã«ã¡ã¢ãpythonã®ãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ããã«ã¯ããã¦ã³ãã¼ããã¦ãã¦â¦
è¶ ãä»ãåºç¤ã§ãããã¤ãã¤ãã©å¿ããã¦èª¿ã¹ãã¯ãã«ãªã£ã¦ãã¾ãã®ã§ã¡ã¢ãã½ã¼ã¹ã³ã¼ãã®ãã絶対ãã¹ãåå¾ããã«ã¯os.pathã使ãã¾ãã #!/usr/bin/python # -*- coding:utf-8 -*- from os import path print __file__ print path.abspath(__file__) prâ¦
NHKã®ãã¢ã³ã«ã¬äºæ³ã¨ãªã¼ãã³äºæ³ã®Youtubeãè¦ã¦ãªãã¨ãªããã£ã¦ã¿ãããªã£ãããªãã¨ãã®ç¯©(ãµãã)ã£ã¦ããã®ã¯è³ã«ãããã¨ããã£ãã®ã§ãã¾ãã¯ããããã£ã¦ãã以ä¸ã®ã½ã¼ã¹ã³ã¼ããeratosthenes.pyã¨ããååã§ä¿åãã¦ã python eratosthenes.py <max number></max>â¦
life timeã¨ããã®ã¯çåæéã¨è¨³ã§ãããã¤ã¾ãããä¸å®ã®æ°å¤åã«ãã©ããããã®é·ããå± ããã¨ãããã¨ã測ãã¾ãããã®è§£æçµæã¯ãã©ã®æ°å¤åããã¨ããå®ç¾©ã«ä¾åãã¾ãã # time value 0 3 1 2 2 3 3 1 4 0 5 1 6 4ãã¨ãã°ãããããã¼ã¿ããã£ãã¨â¦
ãã解æå¤ã®æéå¤åãåºãã¦ããããããpasteã³ãã³ããjoinã³ãã³ãã使ã£ã¦ã¤ãªãããã¨ãããããã¾ãããããããã®æéã¹ã±ã¼ã«ãããããã®çµæã§åããªãã¨ãããã¨ãã°ãä¸æ¹ã¯1000è¡ã¾ã§ãããªãã®ã«ããä¸æ¹ã¯2000è¡ã¾ã§ããæãããã¾ããããâ¦
Pythonã§æå°å¤ãæ±ããã¹ã¯ãªãããæ³å®ãã¦ãããã¼ã¿ã¯ãããªæãã 0 2.87604 2.9828 3.19203 3.6073 3.90156 4.23807 4.24807 3.86984 3.51134 1 2.80487 2.90396 3.15443 3.5649 3.83633 4.19816 4.25518 3.88051 3.54163 2 2.78178 2.87611 3.13413 3â¦
Pythonã¯è±å¯ãªç§å¦æè¡è¨ç®ã©ã¤ãã©ãªãå«ã¾ãã¦ãã¾ãããã®ä¸ã®ä¸ã¤ã«ç¸é¢ä¿æ°ãè¨ç®ãããã®ããã£ãã®ã§ä½¿ã£ã¦ã¿ã¾ãããé©ããã®ã¯ãå¦çãæ©ããã¨æ©ããã¨ã10000çµï¼å¤æ°ã®ç¸é¢ä¿æ°ãä¸ç¬ã§åºãã¦ããã¾ãããnumpyã¢ã¸ã¥ã¼ã«ã®ä¸ã®corrcoefã¨ããâ¦
pythonã¯ã¤ã³ã¿ããªã¿è¨èªã®ç¹æ§ãçããã¦ç°¡åã«ã³ã¼ãä½æãå®è¡ã§ããã®ã§ã¨ã¦ãéå®ãã¦ãã¾ããããã¨ã©ã¼ãå«ãã ã³ã¼ããè¨è¿°ãã¦ããã®å ´æã¾ã§å¦çãé²ã¾ãªãã¨ããããªãã¨ããæ¬ ç¹ãããã¾ããï¼ã·ã§ã«ã¹ã¯ãªããå«ãæ§æãã§ãã¯æ©è½ã®ãªããã¨â¦
ããã¹ã解æã®æã«ããã£ã¨ã¹ã¯ãªãããæ¸ããã¨ããããããã®å ´ãã®ãã§.(ã«ã¬ã³ããã£ã¬ã¯ããª)ãªãã使ã£ã¡ããã¨æ°æã¡ãæªããããããªãã¡ã¤ã«ã«å¦çã渡ãã¦ããå ´åã¯ãã©ãã«ã®åå ã«ããªãã®ã§ãæéã ãã©ä½¿ããã¨ã«ãããã·ã§ã«ã¹ã¯ãªããã®å ´â¦