
Python
Python练习题
乐说数据
极致自律,极致自由。
展开
-
Python操作文件技巧(二)
1. 文件重命名为3位数 (0补齐)import ospath =r'C:\Users\Administrator\Desktop\file'for file in os.listdir(path): name = file.split('.')[0] yuan = os.path.join(path, file) xin = os.path.join(path, '%03d' % int(name) + ".jpg") os.rename(yuan,xin) #原创 2021-02-08 22:22:47 · 278 阅读 · 1 评论 -
Python操作文件技巧(一)
1. 批量删除指定文件夹下面某一格式的文件,比如.js文件import osdef del_files(path): for root,dirs,files in os.walk(path): for name in files: if name.endswith(".js"): os.remove(os.path.join(root,name)) print("Delete File: "原创 2021-01-19 11:37:07 · 210 阅读 · 1 评论 -
时间数据(一)
import pandas as pddata_time = pd.read_csv("demo.csv",engine='python',encoding='gbk')data_time["日期"]=pd.to_datetime(data_time['准确日期'], format='%Y-%m-%d', errors='coerce')data_time.head()data_time['年月'] = data_time['日期'].apply(lambda x: x.strftime("%Y原创 2020-11-18 20:01:31 · 612 阅读 · 0 评论 -
URL地址中汉字的编码转换(Python)
Python3 编码 解码 示例""" utf8 编码"""from urllib.request import quote, unquoteurl1 = "https://www.baidu.com/s?wd=机器学习"# utf8编码,指定安全字符ret1 = quote(url1, safe=";/?:@&=+$,", encoding="utf-8")print(ret1)"""gbk编码"""from urllib.request import quote, unquot原创 2020-10-01 22:47:14 · 1186 阅读 · 0 评论 -
Anaconda安装Tensorflow(CPU版)
打开Anaconda Prompt依次输入以下命令:更改镜像源conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freeconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mainconda config --set show_channel_urls yes创建tensor.原创 2020-10-01 22:36:26 · 588 阅读 · 0 评论 -
anaconda装环境遇到的问题
anaconda装环境遇到无法定位程序输入点OPENSSL_sk_new_reserve……于动态链接库C:\Users...\libssl-1_1-x64.dll解决方法:1. 进入Anaconda\DLLS目录,查看libssl-1_1-x64.dll的日期2. 进入Anaconda\Library\bin目录,比较两者日期3. 如果不一致,将DLLS中的替换bin中的 (注意!是日期早的替换日期晚的!!)...原创 2020-06-16 17:33:09 · 589 阅读 · 0 评论 -
Anaconda中安装第三方库指定镜像源
1. pip安装方法1.1 临时使用:pip install PyQt5 -i https://pypi.tuna.tsinghua.edu.cn/simple/pip install PyQt5-tools -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com1.2 长期使用:在“C:\Users\你的用户名\”目录下创建“pip”目录,“pip”目录下创建“pip.ini”文件(注意:以UTF-原创 2020-06-16 17:26:39 · 19752 阅读 · 0 评论 -
Python程序练习(一)
Python基础 程序的实现(一)'''两整数相加'''a,b=map(int,input().split())print(a+b)# 6 9# 15'''计算圆的面积'''from math import *x=eval(input(""))y=pi*pow(x,2)print('%.7f'%y)# 2# 12.5663706'''1+2+...+n'''n=ev...原创 2020-03-21 18:18:59 · 458 阅读 · 0 评论 -
学习篇—文件处理1
json文件 介绍json是一种轻量级的数据交换格式,本质上就是一个字符串,多个数据用逗号隔开。工具支持的数据格式:1.对象(字典),使用 { }。2.数组(列表),使用 [ ]。3.整型、浮点型、布尔类型还有null类型4.字符串类型(字符串必须用双引号)# 将python对象转化成json字符,dumps转化,dump保存import jsonperson = [ {'us...原创 2020-03-06 15:49:27 · 181 阅读 · 0 评论 -
学习篇—Python 正则表达式
正则表达式 介绍re.findall在字符串中找到正则表达式所匹配的所有子串,并返回一个列表,如果没有找到匹配的,则返回空列表。import restring = 'cell call c.ll cll ceel caal ccll cbll c3ll cAll caall c\nll c ll're.findall('cell',string) #['cell']re.findal...原创 2020-03-07 21:49:24 · 148 阅读 · 0 评论