
Function Languages
文章平均质量分 66
fanbird2008
这个作者很懒,什么都没留下…
展开
-
Python Intro - System Input and Output
#!/usr/bin/pythonimport sysfile_text = ''file_finish = 'file_finish'file_name = raw_input("Enter filename: ")try:# open file stream file = open(file_name, "w")except IOError: p转载 2015-04-10 16:04:20 · 587 阅读 · 0 评论 -
Python Intro - File Operation
#!/usr/bin/pythonimport getopt, sys, urllib, timeimport osdef extract_animation(fname): ofile = fname + ".txt" bWritable = False; try: f0 = open(fname, 'r')原创 2017-02-22 10:35:34 · 355 阅读 · 0 评论 -
Python Intro - Multithread Queue
http://www.runoob.com/python/python-multithreading.htmlPython 多线程多线程类似于同时执行多个不同程序,多线程运行有如下优点:使用线程可以把占据长时间的程序中的任务放到后台去处理。用户界面可以更加吸引人,这样比如用户点击了一个按钮去触发某些事件的处理,可以弹出一个进度条来显示处理的进度程序的运行速度可能加快在一些等转载 2017-04-21 09:43:32 · 447 阅读 · 0 评论 -
Python Intro - Multithread
http://blog.youkuaiyun.com/ajaxuser/article/details/7365436python通过两个标准库(thread, threading)提供了对多线程的支持thread模块import timeimport threaddef runner(arg): for i in range(6): print st转载 2017-04-21 09:44:49 · 619 阅读 · 0 评论 -
Python Intro - VirtualEnviron Setup
1. install Virtualenv sudo pip3 install virtualenv2. create virtualenv agent, python3 -m virtualenv agent3. active python env source agent/bin/activatedeactivate原创 2017-04-21 12:25:10 · 402 阅读 · 0 评论 -
Python Intro - Basic Example
#!/usr/bin/pythondef quicksort(arr): if len(arr) return arr pivot = arr[len(arr) / 2] left = [x for x in arr if x middle = [x for x in arr if x == pivot] righ转载 2017-04-21 17:42:16 · 437 阅读 · 0 评论 -
Python Intro - Functools Usage
#!/usr/bin/pythonimport getopt, sys, urllib, timeimport osfrom functools import *def add(x, y): return x+ydef main(argv): ab = reduce(add, range(1,17)) print(ab)原创 2017-02-23 11:22:38 · 272 阅读 · 0 评论 -
Python Intro - Solve problem of breaking gdb by python
1. On ubuntu, when you compile and install new python, your gdb will fail due to new version python2. for solving the problem, you must let gdb use new python or use old python.3. Here is原创 2015-05-11 14:43:18 · 490 阅读 · 0 评论 -
Python Intro - Parse Command Line Parameters
#!/usr/local/bin/python3import sys, getoptdef main(argv): inputfile = '' outputfile = '' try: opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="]) except getop转载 2015-04-10 16:43:31 · 561 阅读 · 0 评论 -
Python Intro - Compile and Install numpy library on Ubuntu
1. Get the source code of numpy for example: numpy-1.9.2.zip2. Unzip source code zip file unzip numpy-1.9.2.zip3. build and install numpy3.1 enter into numpy-1.9.2 directory原创 2015-04-10 17:54:30 · 463 阅读 · 0 评论 -
Python Intro - C/C++ Extension
Extension Example 1. Python Call C function1.1 spam.c#include static PyObject *SpamError;static PyObject * spam_system(PyObject *self, PyObject *args){ const char *command; int st原创 2015-04-13 16:54:00 · 488 阅读 · 0 评论 -
Python Intro - Numpy Example 01
#!/usr/local/bin/python3try: import numpy as npexcept ImportError: print("numpy is not installed")sizes = [37, 5, 6];#biases = np.array([ 1.0, 3.0, 5.0, 6.0, 7.0]);#weights = np.ar原创 2015-04-14 18:17:05 · 641 阅读 · 0 评论 -
Python Intro - ipdb debug install
1. build and install setuptools1.1 download setuptools setuptools-15.0.tar.gz1.2 unzip setuptools tar xf setuptools-15.0.tar.gz1.3 install setuptools python3 setup.py instal原创 2015-04-15 18:07:25 · 655 阅读 · 0 评论 -
Python Intro - type range and reshape
#!/usr/local/bin/python3try: import numpy as npexcept ImportError: print("numpy is not installed")a = range(9);print(a);print(type(a));#for i in range(9): print(i);x = [t for t原创 2015-04-16 12:27:05 · 613 阅读 · 0 评论 -
Python Intro - pickle binary data (Python3)
1. importerror no module named cpicklecPickle module in Python2 has been replaced by an improved module pickle in Python3. So simply use pickle.2. pickle.load cause UnicodeDecodeError: '原创 2015-04-15 15:50:40 · 3573 阅读 · 0 评论 -
Python Intro - xrange obsoleted by Python3
In Python 3, the range() was implemented like the xrange() function so that a dedicatedxrange() function does not exist anymore (xrange() raises aNameError in Python 3).原创 2015-04-15 16:25:55 · 643 阅读 · 0 评论 -
Python Intro - zip object
#!/usr/local/bin/python3try: import numpy as npexcept ImportError: print("numpy is not installed")sizes = [37, 5, 6];print(sizes[-1]);result = zip(sizes[:-1], sizes[1:]);print(*r原创 2015-04-15 15:51:46 · 1603 阅读 · 0 评论 -
Python Intro - Numpy array shape
#!/usr/local/bin/python3try: import numpy as npexcept ImportError: print("numpy is not installed")sizes = [37, 5, 6];#biases = np.array([ 1.0, 3.0, 5.0, 6.0, 7.0]);#weights = np.ar原创 2015-04-15 12:27:35 · 1146 阅读 · 0 评论 -
Python Intro - Numpy function vectorize
#Numpy vectorize generalized function class#!/usr/local/bin/python3def myfunc(a, b): if(a > b): return a; else: return b;try: import numpy as npexcept ImportError:原创 2015-04-15 11:04:48 · 1525 阅读 · 0 评论 -
Python Intro - network.py migration to Python3
network.py from neural networks and deep learning, but not executabled in Python3The project is comprised of two py files, mnist_loader.py and network.py.The followings are comments on the原创 2015-04-15 17:04:59 · 1677 阅读 · 0 评论