
python
叶铁柱
Better late than never
展开
-
sklearn库(python机器学习)
最近想做个关于tf-idf的实验,找了好多代码都用到了sklearn库,今天先来简单了解一下。sklearn共分为6大部分,分别用于完成分类任务,回归任务,聚类任务,降维任务,模型选择以及数据的预处理。分类任务回归任务聚类任务降维任务...原创 2021-01-11 09:59:55 · 477 阅读 · 0 评论 -
python manage.py runserver 失败
python manage.py runserver(env) root@Lisa:/data/github/uploadFiles # python manage.py runserverWatching for file changes with StatReloaderException in thread django-main-thread:Traceback (most recent call last): File "/data/github/uploadFiles/env/l原创 2021-01-07 10:35:14 · 1418 阅读 · 0 评论 -
ImportError:Couldn‘t import Django
在运行django项目时( python manage.py runserver),报错:root@Lisa:/data/github/uploadFiles # python manage.py runserverTraceback (most recent call last): File "manage.py", line 17, in <module> "Couldn't import Django. Are you sure it's installed and "原创 2021-01-07 10:28:11 · 1773 阅读 · 0 评论 -
Django入门实践
Python的Django框架入门实践https://github.com/LisaYF/myblog.gitgithub.com原创 2021-01-07 10:23:54 · 118 阅读 · 0 评论 -
Python爬虫框架Scrapy实践
本文以豆瓣电影为例,用python的Scrapy框架爬电影的名称、排名、介绍,评价和描述等信息,并存入到mongodb中。https://github.com/LisaYF/douban.gitgithub.com原创 2021-01-07 10:22:47 · 168 阅读 · 1 评论 -
pip install scrapy 失败的解决办法
pip install scrapy 错误信息Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/Collecting scrapy Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/d2/b1/105fe9a289e5bb64ec104076546f72060296d9989a0fc31a8b608c810868/Scrapy-2.2.0-py2原创 2021-01-07 10:21:29 · 911 阅读 · 0 评论 -
python查询数据库
#!/usr/bin/env python# -*- coding: utf-8 -*-import reimport argparseimport osimport commandsimport hashlib import subprocessimport sysimport shutilimport MySQLdbimport MySQLdb.cursorsreload(sys) sys.setdefaultencoding( "utf-8" )class Log: .原创 2021-01-05 13:38:22 · 1057 阅读 · 0 评论 -
Python上传oss
#!/usr/bin/python# -*- coding: UTF-8 -*-import subprocessimport sys, osimport commandsimport oss2def upload_to_update_oss(oss_src,file_path,file_name): # 上传json到OSS auth = oss2.Auth('名称', '密码') bucket = oss2.Bucket(auth, '域名', 'bucket名称.原创 2020-12-30 11:17:34 · 317 阅读 · 0 评论 -
python-根据url获取文件名
#!/usr/bin/python# -*- coding: UTF-8 -*-import sys, osimport commandsimport urllibdef get_filename(url_str): url = urlparse(url_str) i = len(url.path) - 1 while i > 0: if url.path[i] == '/': break i = i - 1.原创 2020-12-30 11:16:17 · 935 阅读 · 0 评论 -
python-touch()
#!/usr/bin/python# -*- coding: UTF-8 -*-import sys, osimport commandsdef Touch(file_name,file_path): os.chdir(file_path) if file_name in os.listdir('.'): print("file exist!") else: print("creating %s" %file_name) f.原创 2020-12-30 11:14:40 · 797 阅读 · 0 评论 -
Python-已知url下载文件
#!/usr/bin/python# -*- coding: UTF-8 -*-import sys, osimport commandsimport urllibdef download(url_str,save_path,filename): full_path = save_path + '/' + filename Log.i("full_path:"+full_path) try: urllib.urlretrieve(url_str,full.原创 2020-12-30 11:13:29 · 296 阅读 · 0 评论 -
python-获取md5值
#!/usr/bin/python# -*- coding: UTF-8 -*-import hashlib import subprocessimport sys, os_FILE_SLIM=100*1024*1024def File_md5(filepath): calltimes = 0 hmd5 = hashlib.md5() fp = open(filepath, "rb") f_size = os.stat(filepath).st_size .原创 2020-12-30 11:12:21 · 224 阅读 · 0 评论 -
Python-log彩色打印
#!/usr/bin/python# -*- coding: UTF-8 -*-class Log: @staticmethod def e(msg): print(Log.red + '[x]:' + msg + Log.end) @staticmethod def w(msg): print(Log.yellow + '[!]:' + msg + Log.end) @staticmethod def i(msg): .原创 2020-12-29 14:54:21 · 190 阅读 · 0 评论 -
python下载json文件并重写
#!/usr/bin/python# -*- coding: UTF-8 -*-import subprocessimport sys, osimport commandsimport shutilimport reimport hashlib import urllibimport oss2import argparsefrom urlparse import urlparseimport timeimport randomimport jsonfrom xml.etree.原创 2020-12-29 14:49:55 · 337 阅读 · 0 评论 -
python-查询数据库-匹配数据
#!/usr/bin/env python# -*- coding: utf-8 -*-import reimport argparseimport osimport commandsimport hashlib import subprocessimport sysimport shutilimport MySQLdbimport MySQLdb.cursorsreload(sys) sys.setdefaultencoding( "utf-8" )class Log: .原创 2020-12-29 14:47:12 · 474 阅读 · 0 评论 -
Python判断字符串包含关系
#!/usr/bin/env python#encoding:utf-8# 1.in 方法str_test="the family can mutually close cooperation, is the only real happiness in the world.\njust test."print str_teststr2="family"if str2 in str_test: #注意必须是单引号 print "Found '"+str2+"' in the strin.原创 2020-12-25 16:46:29 · 431 阅读 · 1 评论 -
No module google.protobuf
1.执行python脚本报错:报错:No module named google.protobuf2.于是用pip安装protobuf#命令:失败LisaMacBook:sudo pip install protobufLisaMacBook:The directory '/Users/???/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache原创 2020-12-18 10:32:41 · 1016 阅读 · 0 评论 -
python入门复习-3
就两部分内容,瞄一眼就行十、文件和异常1、从文件中读取数据#1-读取整个文件with open(test.txt) as file_object: contents=file_object.read() print(contents)#2-文件路径:相对于当前目录,也可以填写绝对路径with open(test/test.txt) as file_object:#3-逐行读取文件with open(test.txt) as file_object: for l原创 2020-12-18 10:21:32 · 378 阅读 · 0 评论 -
python自动化常用模块
#!/usr/bin/env python# -*- coding: utf-8 -*-import subprocessimport sys, osimport commandsimport shutilimport reimport hashlib import urllibimport oss2import argparsefrom urlparse import urlparseimport timeimport randomimport jsonfrom xml..原创 2020-12-15 09:53:07 · 122 阅读 · 0 评论 -
Python入门复习-1
二 变量与简单数据类型2.3 字符串 大小写:title(首字母大小写),upper(大写),lower(小写) 拼接:+ 添加空白:\t 删除末尾空白:rstrip() 剔除开头空白:lstrip() 同时剔除两端空白:strip() Python3:print() 必须加括号,Python2可以不用加 2.4 数字 print中使用str()避免类型错误 3/2=1,3.0/2=1.5 三 列表 [ ]原创 2020-12-17 10:33:49 · 110 阅读 · 0 评论 -
Python入门复习-2
总体很简单,就是想复习复习,找找被自己遗漏的知识点六 字典1、格式:alien={'color':'green','points':5}2、添加键值对:alien['x_position']=03、创建一个空指点:alien={}4、删除键值对:del alien['points']5、遍历字典:for key, value in alien.items():对于key, value这两个变量,可以使用任何名称6、遍历字典中的所有键:for name in alien.key原创 2020-12-17 10:43:44 · 137 阅读 · 1 评论 -
python class 从数据库获取对应版本号
#!/usr/bin/python# -*- coding: UTF-8 -*-import MySQLdbimport MySQLdb.cursorsimport sys reload(sys) sys.setdefaultencoding( "utf-8" )class Log: @staticmethod def e(msg): print(Log.red + '[x]:' + msg + Log.end) @staticmethod .原创 2020-12-16 10:20:27 · 186 阅读 · 0 评论 -
UnicodeEncodeError(python修改xml或json)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 53-56: ordinal not in range(128)当我们用Python修改xml或者json文件的时候,通常会遇到”UnicodeEncodeError”的问题,百度谷歌的方法千千万,有时候看了一大丢都发现解决不了问题,这里备注两种我试过可行的方法;1.python修改xml时,在开头加上- import sys- reload...原创 2020-12-16 10:09:05 · 207 阅读 · 0 评论 -
python os.path常用模块(os.path.exists)
#!/usr/bin/python# -*- coding: UTF-8 -*-import osclass Log: @staticmethod def e(msg): print(Log.red + '[x]:' + msg ) @staticmethod def w(msg): print(Log.yellow + '[!]:' + msg ) @staticmethod def i(msg): p.原创 2020-12-16 10:06:01 · 1226 阅读 · 0 评论