Python
vwenyu-L
这个作者很懒,什么都没留下…
展开
-
jupyter notebook-远程登录服务器
jupyter notebook --generate-configjupyter notebook password~/.jupyter/jupyter_notebook_config.py ~/.jupyter/jupyter_notebook_config.json c.NotebookApp.ip='*'c.NotebookApp.password = u'sha:ce..'...原创 2018-03-13 14:39:16 · 520 阅读 · 0 评论 -
python-str-format
'{:0.6f}'.format(i) 小数点后保留6位 补0'{:.6f}'.format(ii) 六位有效数字 '{:0>4}'.format(i) 四位有效数字 左补0'{:0<4}'.format(i) 四位有效数字 由补0原创 2016-10-02 17:02:21 · 634 阅读 · 0 评论 -
python-csv
with open('./data/data/eth/hotel/pixel_pos.csv', 'rb') as f: raw_data = csv.reader(f) data = np.zeros((4, 6544)) for i,line in enumerate(raw_data): data[i, :] = line原创 2016-12-09 16:24:45 · 600 阅读 · 0 评论 -
python-PIL
----------------------------https://www.daniweb.com/programming/software-development/code/216637/resize-an-image-python原创 2017-06-30 22:30:39 · 335 阅读 · 0 评论 -
python-sympy
symbolic computation原创 2016-10-31 18:42:47 · 398 阅读 · 0 评论 -
python-class__dict__setattr__getattr__
In [153]: class test(object): ...: def __init__(self, a, b): ...: self._cont = {} ...: self.a = a ...: self.b = b ...: #self._cont = {}原创 2017-06-22 15:54:50 · 465 阅读 · 0 评论 -
python-class
namespacescopemethodclass level ...objectinstanceself__init__(self, ...):原创 2016-10-17 21:41:20 · 261 阅读 · 0 评论 -
python-pythonic
1. dictdict.setdefault('key', []).append('test')-for k,v in dict.iteritems(): print k,vdict.get(key, 'otherwise')2. use build-in functionreversed()enumerate()sorted([1,2,3], rev原创 2017-04-24 16:08:42 · 361 阅读 · 0 评论 -
python-pandas
0.pd.read_csv()1. .columns.index原创 2017-05-06 10:34:17 · 216 阅读 · 0 评论 -
python-strip lstrip rstrip
str.strip()str.lstrip('0')str.rstrip('0')原创 2017-05-13 15:46:14 · 435 阅读 · 1 评论 -
numpy-nditer
-------------------------reference---------------1. https://docs.scipy.org/doc/numpy/reference/generated/numpy.nditer.html2. http://blog.csdn.net/lanchunhui/article/details/55657135原创 2017-04-19 16:46:57 · 1284 阅读 · 0 评论 -
python-skimage
1. skimage.utilcroppadrandom_noiseregular_gridview_as_windowsview_as_blcks2. skimage.transformimg = np.array(img, dtype=float)resize(img, [], order=1) 0-nearest 1-bilinear 3-cub原创 2017-07-02 21:08:40 · 1690 阅读 · 0 评论 -
python-bisect/np-searchsorted
bisect()np.searchsorted()原创 2017-07-20 13:28:11 · 404 阅读 · 0 评论 -
python-pypdf2
from PyPDF2 import PdfFileWriter, PdfFileReaderpdf_input = PdfFileReader(open('xx.pdf', 'rb'))pdf_output = PdfFileWriter()print(pdf_input.numPages)page = pdf_input.getPage(0) #pdf_output.addPa原创 2017-07-21 17:07:51 · 1378 阅读 · 0 评论 -
python-conda
1. 不同版本的python管理conda update condaconda create -n python35 python=3.5原创 2017-11-23 21:59:38 · 1127 阅读 · 0 评论 -
vs-code tips
setting-shortcuts 功能 操作 ctl+d select words [one or more times] alt+cursor select multis position or lines alt+shift+mouse select multi columnsdebugchoose and open launch.jsonstart deb原创 2017-11-20 20:33:24 · 303 阅读 · 0 评论 -
python-itertools
itertools.product()itertools.permutations()itertools.combinations()---------------------reference--------------------1. http://www.wklken.me/posts/2013/08原创 2017-04-19 21:55:37 · 422 阅读 · 0 评论 -
python-os
path.path = os.path.abspath(__file__)dir = os.path.dirname(path)os.path.split(path)os.path.exists(path)原创 2017-08-01 21:10:30 · 333 阅读 · 0 评论 -
python-argparse
parser = argparse.ArgumentParser()parser.add_argument('echo')parser.add_argument('-num', typr=int, default=0)args = parser.parse_args()print(args.echo, args.num)原创 2017-07-24 14:03:05 · 279 阅读 · 0 评论 -
python-heapq
top_ka = []k = 6heapq.heappush(a, ele)heapq.heappop(a)heapq.heareplace(a, ele)原创 2017-07-29 15:29:13 · 309 阅读 · 0 评论 -
python-language/tips/
------------0----glob-------------xx = glob.glob('xxx') [] * . return listyy = glob.glob('xxx') return generator---------1---------原创 2016-03-24 19:13:18 · 339 阅读 · 0 评论 -
python-super
cls.mro()method resolution oderdef super(cls, inst): mro = inst.__class__.mro() return mro[mro.index[cls] + 1]原创 2017-07-29 13:55:21 · 280 阅读 · 0 评论 -
python-read the file contains Chinese
import codecswith codecs.open(u'../../../Data/Car/20170111/result/honda_data.txt', 'w', 'utf-8') as f:with codecs.open('../../../Data/Car/20170111/result/honda_data.txt', 'r', 'utf-8') as f:patter原创 2017-01-17 14:02:33 · 341 阅读 · 0 评论 -
python-implement global var using attr of function
def test(): try: test.count+=1 except AttributeError: test.count =1 passtest()test()test()原创 2016-06-23 21:39:54 · 315 阅读 · 0 评论 -
python-urllib/urllib2
1. download image given urlurllib.urlretrieve(url, filename2save)with opwn(filename2save, 'wb+') as f : f.wtite( urllib2.urlopen(url).read() )原创 2016-10-24 16:32:29 · 351 阅读 · 0 评论 -
python-numpy-01
1. import numpy as npa = np.array([[1,2,3,3],[2,3,3,4],[2,3,3,4]]) #[[1 2 3 3] #[2 3 3 4] #[2 3 5 4原创 2016-10-28 16:14:13 · 289 阅读 · 0 评论 -
python-scipy
scipy --- python原创 2016-07-23 08:39:11 · 425 阅读 · 0 评论 -
python-pickle/cPickle/glob/tarfile
try: import cPickle as pickleexcept: import pickleawith open(file, 'wr') as f: pickle.dump(a, f, -1)with open(file) as f: a = pickle.load(f)原创 2016-07-22 19:44:28 · 376 阅读 · 0 评论 -
python-collections/itertools
python-collections/itertools原创 2016-07-23 08:52:48 · 332 阅读 · 0 评论 -
python-lmdb
-----------write---------------import lmdbenv_db = lmdb.Environment('path-to-save', xxx)txn = env_db.begin( write=True, buffer=True)txn.put( key, value)txn.commit()env_db.close()----原创 2016-04-27 20:58:49 · 1831 阅读 · 0 评论 -
python-pandas
------reference------------[1]. http://nbviewer.jupyter.org/github/rasbt/python_reference/blob/master/tutorials/things_in_pandas.ipynb#Applying-Computations-Rows-wise[2]. http://pandas.pydata.org/原创 2016-04-15 20:56:05 · 340 阅读 · 0 评论 -
python-set
for -> speed slowset(a) ^ set(b)set(a).intersection( set(b) )set(a).union( set(b) )set(a).difference( set(b) )原创 2016-10-25 14:09:14 · 389 阅读 · 0 评论 -
python-threading
https://docs.python.org/2/library/multiprocessing.html原创 2016-10-26 14:57:28 · 256 阅读 · 0 评论 -
python-gui
-----------------------------reference------------------1. http://www.xuebuyuan.com/1918954.html原创 2017-02-13 10:17:57 · 341 阅读 · 0 评论 -
python-matplotlib
test = plt.get_cmap('Paired', 10)plt.imshow(x, cmap=test, interpolation='None') or plt.matshowplt.colorbar(ticks=range(0, 10))原创 2016-12-04 11:47:30 · 509 阅读 · 0 评论 -
python-argparse
import argparseparse = argparse.ArgumentParse(description="", usage="")parse.add_argument("-s", "--something", type=str/int/float, default=x, required=Ture/False, help="")args = parse.parse_args原创 2016-07-26 19:30:03 · 307 阅读 · 0 评论 -
python-logging
logging.warning()logging.debug()logging.info()logging.error()logging.critical()原创 2016-11-02 10:04:25 · 270 阅读 · 0 评论 -
python-numpy-00
ndarray.flatten('C' or 'F') plt.hist( ndarr , bins=xxx, normed = 1, )原创 2016-03-26 16:12:57 · 506 阅读 · 0 评论 -
python-ipyhton notebook
1. 远程ipythonhttp://ipython.org/ipython-doc/dev/notebook/public_server.html#notebook-public-server2. 远程matlab原创 2016-06-11 18:53:55 · 411 阅读 · 0 评论 -
python-module/package
import some-model : three things will be done1. 2. 3.----------------reference---------------------------0. http://blog.csdn.net/zyz511919766/article/原创 2016-10-04 12:41:12 · 249 阅读 · 0 评论