python
cainiao22222
这个作者很懒,什么都没留下…
展开
-
python多级目录复制制定类型文件,并保存到对应目录
情景如下:提取result文件夹下的除".txt"文件最终效果:# coding=UTF-8import osimport shutildef get_file(root_path,all_files=[]): ''' 递归函数,遍历该文档目录和子目录下的所有文件,获取其path ''' files = os.listdir(root_path) for file in files: if os.path.isdir原创 2020-07-30 11:11:39 · 826 阅读 · 0 评论 -
python 实现N级目录创建,且每级目录放置文件
python 实现N级目录创建,且每级目录放置文件# coding=UTF-8import osimport sysimport shutilimport Tkinter, tkFileDialog############每层只有一个文件夹def mkdirwenjian_one(nums_high,rootpath): print rootpath for i in range(nums_high): rootpath = rootpath + '/'原创 2020-07-27 17:32:00 · 463 阅读 · 0 评论 -
LeetCode算法刷题——数组篇
算法刷题——数组篇1. 双指针(快慢指针)1. 双指针(快慢指针)简单篇1 给定一个排序数组,你需要在 原地 删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额外空间的条件下完成。 def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """原创 2020-06-01 15:44:28 · 425 阅读 · 0 评论 -
python 获取天气接口数据
从微信公众号中看到的代码,以此记录用Python获取中国天气网天气接口数据import urllib.requestimport jsoncode='101160101'url='http://www.weather.com.cn/data/cityinfo/%s.html'% codeprint('url=',url)obj=urllib.request.urlopen(ur...转载 2018-09-06 10:40:07 · 1656 阅读 · 0 评论 -
python 面向对象笔记
Python 面向对象小结,最近在学习Python,在学习到面向对象时有些记不住,特写此笔记:1.定义类 class People: num = 0 def SayHello(self): print("Hello");2.定义对象 P = People() p.SayHello()3.构造函数__init__(...原创 2018-09-19 21:38:43 · 261 阅读 · 0 评论 -
基于用户的协同过滤电影推荐
基于用户的协同电影推荐代码实现:# -*- coding: UTF-8 -*-'''基于用户的推荐算法'''from math import sqrt,powimport csvimport operatordef read_file(): #disfile = 'F:\download\数据集\电影\ml-latest-small\matings.csv' w...原创 2019-01-05 14:48:38 · 1884 阅读 · 1 评论
分享