Python
henry860916
水滴石穿
展开
-
Python---dict
'''help---dict1. key-value2. key is not repeated, later key value will cover old key value'''dict1={'name':'xfei','age':20, 'favorite':['swimming','singing','film']}print(dict1)print(dict1['name原创 2015-12-28 20:04:13 · 219 阅读 · 0 评论 -
Python---常见问题
1. 如何查找自动加载的模块>>> import builtins>>> dir(builtins) 2. 如何知道函数返回的数据类型type(object)3.文件夹操作os.os.pathshutil.4.字符串操作str5.调用shell命令(详见shell.txt)a. os.system()b. os.popen()c. comm原创 2015-12-28 20:19:09 · 432 阅读 · 0 评论 -
Python---http
import urllib.request as urimport http.client as hcimport httplib2import urllib.parse as updef http1(): print('==========http1================================') url='http://www.njzz.gov.cn/Pad/原创 2015-12-28 20:12:18 · 317 阅读 · 0 评论 -
python 的打包及安装 distutils
命令如下:python setup.py --help-commands python setup.py sdist 创建一个源码包发布 python setup.py bdist 创建一个二进制包发布 以什么样的格式打包zip,tar,rpm 可以通过以下命令查看:python setup.py sdist --help-formatspython setup.p原创 2015-12-31 21:14:28 · 1789 阅读 · 0 评论 -
spark 命令行环境 python
1. 安装python,安装好后查看python版本$ python --versionPython 2.7.6从下面的pyspark.sh中可以看出,默认是支持2.7的python(spark版本是spark-1.6.0-bin-hadoop2.6)if hash python2.7 2>/dev/null; then # Attempt to use Python 2.7,原创 2016-01-24 10:09:35 · 7659 阅读 · 0 评论 -
rest/flask/nginx/uwsgi/supervisor
感谢原文作者http://www.cnblogs.com/Ray-liang/p/4173923.html?utm_source=tuicool&utm_medium=referral我采用的部署方案是:Web 服务器采用 uwsgi host Flask用 Supervisor 引用 uwsgi 作常规启动服务基于 Nginx 作反向代理首先, 阿里云服务器可以通过 SSH 指令在本机的终端进转载 2017-11-16 11:23:07 · 463 阅读 · 7 评论 -
flask rest
转载于:https://www.cnblogs.com/knarfeh/p/5616515.html环境简介Ubuntu我使用的 Ubuntu 系统版本是 14.04,用过几个 Linux 发行版,现在挑选系统的第一选择基本就是 Ubuntu 了,因为 Ubuntu 有商业公司Canonical 做开发维护;使用的人多,有庞大的社区支持;遇到问题容易解决。我折腾过很长时间的转载 2017-11-16 11:34:40 · 618 阅读 · 0 评论 -
AI
Good resources I used to use ^^机器学习coursea课程:AndrewNg https://www.coursera.org/learn/machine-learning#syllabus 机器学习实战(Peter):https://book.douban.com/subject/24703171/ 机器学习(周志华):https://book.douban原创 2018-02-05 21:05:17 · 402 阅读 · 0 评论 -
kaggle base line: Mercari Price Suggestion Challenge
import mathimport numpy as npimport scipy as spimport matplotlib.pyplot as pltimport pandas as pdfrom pandas import *import sklearnfrom sklearn.preprocessing import *from sklearn.feature_sel原创 2018-02-05 20:31:39 · 556 阅读 · 0 评论 -
kaggle---titanic
import numpy as npimport scipy as spimport matplotlib.pyplot as pltimport pandas as pdfrom pandas import *from test import *from pandas import DataFramefrom sklearn.ensemble import RandomFore原创 2018-02-06 10:58:34 · 304 阅读 · 0 评论 -
Kaggle solution 1: Mercari Price Suggestion Challenge
import pandas as pdimport numpy as npimport scipyimport mathimport timefrom sklearn.linear_model import Ridge, LogisticRegressionfrom sklearn.model_selection import train_test_split, cross_val_原创 2018-02-07 10:07:11 · 841 阅读 · 0 评论 -
Python---httplib2
import urllib.request as urimport http.client as hcimport httplib2import urllib.parse as updef httplibtwo1(): print('===================httplib2========================') url='http://www.12306.原创 2015-12-28 20:18:12 · 479 阅读 · 0 评论 -
Python---function call
util_m.py: import sysdef util_test(string): ''' parameter description: string: string of object return none ''' print(string)list1=['1',2,3,4]def built(): hello()def is_less_than1原创 2015-12-28 20:16:34 · 679 阅读 · 0 评论 -
Python---unit test
'''TDD: test drive develop'''import unittestimport util_mclass myunittestclass(unittest.TestCase): '''must be the child class of unittest.TestCase''' values=[1,2,3,4,5,6,7,10] def test_is_less原创 2015-12-28 20:15:25 · 294 阅读 · 0 评论 -
Python---list
'''help--list1.not special restrict'''a_list = ['xfei',22,'nanjing']print(a_list)print(a_list[2])print(a_list[-1])print(a_list[0])print(a_list[-3])print(a_list[0:2])print(a_list[:3])print原创 2015-12-28 20:05:25 · 213 阅读 · 0 评论 -
Python---set
'''help---set, 1. no sequencial, random2. no repeated value'''my_set={1,'data1',2,'value'}print(my_set)a_list = [1,2,3]tt_set=set(a_list)print(tt_set)print(len(my_set))my_set.add('33333')pr原创 2015-12-28 20:05:58 · 205 阅读 · 0 评论 -
Python---tuple
'''help---tuple1. can not change 2. only can access'''my_tuple=('data1',222,222,'data3',333,444,'jang')print(my_tuple)print(my_tuple[0])print(my_tuple[0:])print(my_tuple[:-1])print(my_tuple[:原创 2015-12-28 20:06:32 · 285 阅读 · 0 评论 -
Python---string
'''help--string'''import sysimport util_mlist_1=[1,43,161,12]i=0for item in list_1: if item%2!=0: print(item) i=i+1 else: breakprint('total:')print(i)name='xfei'password='123456'pri原创 2015-12-28 20:07:08 · 253 阅读 · 0 评论 -
Python---re
'''help----re'''import restring1='100 NORTH BROAD MAIN ROAD. 100'print(string1.replace('ROAD.', 'RD.'))print(re.sub('ROAD$', 'RD.', string1))print(re.sub('^100', '200', string1))'''$ means endw原创 2015-12-28 20:08:26 · 215 阅读 · 0 评论 -
Python---generator
import re'''method1============================================================'''def matchx(noun): return re.search('[szx]$', noun)def matchy(noun): return re.search('[yam]$', noun)def applyx原创 2015-12-28 20:09:00 · 239 阅读 · 0 评论 -
Python---os
'''help----os, help----glob'''import osimport timeimport globprint(os.getcwd())os.chdir('/home/tizen/share')print(os.getcwd())path='/home/tizen/share/tools/python'path2='/home/tizen/share/too原创 2015-12-28 20:09:32 · 251 阅读 · 0 评论 -
Python---serial
import pickleimport pickletoolsimport jsondef pickle1(): list1={} list1['name']='jack' list1['age']=22 with open('data.pickle', mode='wb') as file: pickle.dump(list1, file)def pickle2():原创 2015-12-28 20:10:10 · 361 阅读 · 0 评论 -
Python---class and iter
import itertoolsimport subprocessimport util_m'''it is for shell command'''import builtins'''it is loaded into memory when python module starts'''class myclass1: pass'''pass means {} in java原创 2015-12-28 20:10:55 · 291 阅读 · 0 评论 -
Python---file
import localeimport ioimport gzipimport sysclass RedirectStdoutTo: def __init__(self, out_new): self.out_new = out_new def __enter__(self): self.out_old=sys.stdout sys.stdout=self.out_new原创 2015-12-28 20:11:33 · 405 阅读 · 0 评论 -
Python---xml
'''import xml.etree.ElementTree as etreeElementTree is default python module, but it is slow, function is limitedso , we can import etree from lxml, it has the same api.'''from lxml import etree'原创 2015-12-28 20:13:26 · 303 阅读 · 0 评论