<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[Joseph的编程学习之旅]]></title><description><![CDATA[记录小学生学习编程的过程]]></description><link>https://blog.youkuaiyun.com/pebbleren</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; pebbleren]]></copyright><item><title><![CDATA[26获取文件名]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108241383</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108241383</guid><author>pebbleren</author><pubDate>Wed, 26 Aug 2020 15:53:45 +0800</pubDate><description><![CDATA[1.使用with open函数，为了将文件名保存在TXT文件里

2.获取文件夹路径

3.for循环和os.path.splitext函数获取名字

4.with open函数写入文件


import os

with open('X:\\Users\\Administrator\\Desktop\\python\\python 编程锦囊\\27文件.txt','a') as f:
    path = input('请输入要提取名称的文件所在路径：')
    try:
        list = ]]></description><category></category></item><item><title><![CDATA[25打开文件]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108241332</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108241332</guid><author>pebbleren</author><pubDate>Wed, 26 Aug 2020 15:49:52 +0800</pubDate><description><![CDATA[1.使用while True循环

2.获取文件路径

3.os.startfile函数打开文件夹


import os
while True:
    try:
        path = input('请输入文件所在路径')
        os.startfile(path)
    except:
        print('请输入一个存在的路径')


...]]></description><category></category></item><item><title><![CDATA[24重命名文件]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108218471</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108218471</guid><author>pebbleren</author><pubDate>Tue, 25 Aug 2020 11:54:49 +0800</pubDate><description><![CDATA[1.获取文件的路径

2.os.listdir模块遍历路径里的文件

3.获取文件名

4.if语句判断是否为文件

5.获取拓展名

6.将新的文件名（字符串就行）和文件后缀拼接在一起

7.使用os模块的函数进行重命名

代码：



import os
while True:
    path = input('请输入要重名的文件所在路径：')
    try:
        list = os.listdir(path)
        mum = 0
        for i in rang.]]></description><category></category></item><item><title><![CDATA[23生成文件夹]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108218300</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108218300</guid><author>pebbleren</author><pubDate>Tue, 25 Aug 2020 11:45:52 +0800</pubDate><description><![CDATA[1.用变量保存一个绝对路径（路径后要加 ‘/’,python里要将路径里的 ‘\’换成 ‘/’）

2.使用TXT文本文档保存文件夹名字，如：

3.With open函数打开文件

4.for循环遍历文件并拼接出文件夹的绝对路径

5.if语句检测是否存在同名的文件夹

6.创建文件夹

代码：



import os
path = 'X:/Users/Administrator/Desktop/新建文件夹/'
with open('24生成文件夹的文件.txt','r',encoding='utf..]]></description><category></category></item><item><title><![CDATA[22根据时间创建文件]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108197397</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108197397</guid><author>pebbleren</author><pubDate>Mon, 24 Aug 2020 13:28:02 +0800</pubDate><description><![CDATA[1.使用while循环

2.input函数获取文件地址和文件数量

3.获取时间

4.格式化文件路径

5.创建文件，编码是utf-8

6.等待1秒，给代码足够创建文件的时间

7.打开文件页面


import os
import datetime
import time
while True:
    path = input('请输入文件保存地址；')
    num = int(input('请输入创建文件数量'))
    for i in range(num):
        t = d]]></description><category></category></item><item><title><![CDATA[21显示连接字符串的时长]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108197333</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108197333</guid><author>pebbleren</author><pubDate>Mon, 24 Aug 2020 13:16:28 +0800</pubDate><description><![CDATA[1.‘+’号直接连接

1.使用datetime函数记录开始时长

2.使用for循环将循环变量和字符串拼接

3.datatime记录结束时长

4.print输出时长


import datetime
st = datetime.datetime.now()
s = ''
for i in range(0,10000):
    s +=str(i)
et = datetime.datetime.now()
print(et-st)


0:00:00.005005

2.列表连接

1.使用date]]></description><category></category></item><item><title><![CDATA[20将密码加密]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108179392</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108179392</guid><author>pebbleren</author><pubDate>Sun, 23 Aug 2020 09:34:11 +0800</pubDate><description><![CDATA[1.导入hashlib模块

input函数获取密码

使用MD5加密（utf-8格式）

print输出


import hashlib
str = input('请输入密码：')
md5 = hashlib.md5()
md5.update(str.encode('utf-8'))
print('MD5加密：',md5.hexdigest())

结果：


请输入密码：1234
MD5加密： 81dc9bdb52d04dc20036dbd8313ed055

2.SHA1加密，同1，将代码中的MD5]]></description><category></category></item><item><title><![CDATA[19显示文字的区位码]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108179321</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108179321</guid><author>pebbleren</author><pubDate>Sun, 23 Aug 2020 09:20:29 +0800</pubDate><description><![CDATA[1.input函数获取文字信息

2.GB2312内码减去160的16进制就等于区位码，所以先用encode编码函数调用GB2312内码

3.使用format格式化得出区位码

4.for循环+print函数输出结果

代码：


def getCode(chinese):
    branny = chinese.encode('gb2312')
    code = '{0:02d}'.format((branny[0]-160))+'{0:02d}'.format((branny[1]-160))
]]></description><category></category></item><item><title><![CDATA[18将中文按照拼音的顺序进行排序]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108169619</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108169619</guid><author>pebbleren</author><pubDate>Sat, 22 Aug 2020 15:51:17 +0800</pubDate><description><![CDATA[1.设立一个需要排序的表

2.使用for循环将列表里的内容进行转换

3.将列表排序（按照英文字母的顺序）

4.for循环将数据添加到列表里

5.print（）输出

代码：


from xpinyin import Pinyin
def my_soft(wordlist):
    pin = Pinyin()
    temp = []
    for item in wordlist:
        temp.append((pin.get_pinyin(item),item))
    t]]></description><category></category></item><item><title><![CDATA[17随机输出姓名]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108152293</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108152293</guid><author>pebbleren</author><pubDate>Fri, 21 Aug 2020 17:47:35 +0800</pubDate><description><![CDATA[1.将姓氏，名字的第二个字，名字第三个字用变量分别创建字库


surname = '赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许'
second ='中万斯近元伟丽利陈国士文连百宏立成海友南广云基天明'
third = '隆智渝顺乐天杰夫陈兵思霆炜祺亮剀炫翔维瑞稻嘉林庆伟勤栋源路焕霖彩明邦闻朵浩翰荣奕涓艺'

2.input函数获取要输出几个姓名

3.for循环里使用random随机数函数随机出是要打印出两个字的名字还是三个字的名字

4.if语句进行判断，并再次使用random函数将变量里的文字随机提取出]]></description><category></category></item><item><title><![CDATA[15模拟数据验证]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108025353</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108025353</guid><author>pebbleren</author><pubDate>Sat, 15 Aug 2020 17:15:43 +0800</pubDate><description><![CDATA[1.使用字符串的各种函数进行检查验证

1.使用input函数和if语句检测用户输入的信息

2.使用if语句和isdigit函数检测输入的信息是否为数字

3.if语句检测信息是否为空

4.print输出信息

代码：



instr = input('请输入：')
if str.isdigit(instr):
    if instr == '0':
        print('\033[1;31;40m 输入为0，请重新输入！\033[0m')
    else:
        print(.]]></description><category></category></item><item><title><![CDATA[14实现数据编号]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/108005059</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/108005059</guid><author>pebbleren</author><pubDate>Fri, 14 Aug 2020 15:21:12 +0800</pubDate><description><![CDATA[1.zfill函数编号

1.写一个字符串，以‘，’号分割，空格将文字和数字分割


data = '莱科宁 236,汉密尔顿 358,维泰尔 294,维斯塔潘 216,博塔斯 227'

2.将字符串按照‘，’号进行分割

3.使用for循环按空格进行分割，并将数据传到列表里

4.使用sort函数进行升序排列

5.输出标题，for循环输出数据

代码：


datasort = []
i = 0
data = '莱科宁 236,汉密尔顿 358,维泰尔 294,维斯塔潘 216,博塔斯 227'
fg]]></description><category></category></item><item><title><![CDATA[13对齐中英文文字]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107959017</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107959017</guid><author>pebbleren</author><pubDate>Thu, 13 Aug 2020 13:20:37 +0800</pubDate><description><![CDATA[解决方案：

1.将数值保存到txt文件里

2.将数值格式化，保存到列表里

3.打印出标题

4.用for循环计算出需要空几个空格

5.格式化打印出信息

代码：


menu='球员        球队        总得分       场均得分      总篮板       场均篮板      '
cba=[]

for line in open('cba.txt'):
    new = line.replace('\t',',')
    over = new.replace('\n', '']]></description><category></category></item><item><title><![CDATA[12使用条形统计图显示数据]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107957183</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107957183</guid><author>pebbleren</author><pubDate>Wed, 12 Aug 2020 15:09:04 +0800</pubDate><description><![CDATA[1.横板条形统计图

实现方式

1.将数据存放在列表里，把数据除以300

2.输出数据标题名称

3.将除以300后的数据再乘一个符号（输出几个符号），这样能更直观的的查看数据

4.输出符号（也可以将符号加上背景颜色，这样看上去更美观）

代码：


sj=[['alibaba',4580],['amazon',9628],['apple',11331],['oracle',2053]]
hchartall=300
mark='41m'
for item in Stark:
    jh=int(it]]></description><category></category></item><item><title><![CDATA[11.去掉字符串或列表内重复的内容]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107937138</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107937138</guid><author>pebbleren</author><pubDate>Tue, 11 Aug 2020 16:04:53 +0800</pubDate><description><![CDATA[1.字符串去重

1.使用for循环和if语句去重，将不重复的数值提取出来

代码：


name='1234564789'
newname=''
for i in name:
    if i not in newname:
        newname+=i
print(newname)

结果：

123456789

2.while语句去重，顺序相反，因为i是从大到小去减

代码：


name='1234564789'
newname=''
i = len(name)-1
while True:]]></description><category></category></item><item><title><![CDATA[10将字符串，列表或字典里的内容拼接起来的几种方法]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107936249</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107936249</guid><author>pebbleren</author><pubDate>Tue, 11 Aug 2020 15:41:16 +0800</pubDate><description><![CDATA[1.字符串拼接

1.用+号拼接字符串，将两个字符串之间写入+号即可

代码：


data='www.'+'mingrisoft'+'.com'
train1='www.'+str(12306)+'.com'
train2='www.'+'12306'+'.com'
print(data)
print(train1)
print(train2)

结果：

www.mingrisoft.com
www.12306.com
www.12306.com

2.用‘，’号拼接字符串，和+号的方法一样，这里我们做]]></description><category></category></item><item><title><![CDATA[9清除列表和字符串里不必要的内容]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107911443</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107911443</guid><author>pebbleren</author><pubDate>Mon, 10 Aug 2020 13:53:39 +0800</pubDate><description><![CDATA[要求：用各种方法将列表或字符串里的数值清除

1.用strip（）函数可以清除字符串两边的空格

2.strip（）搭配列表推导式可以清除所有的空格

3.用split（）函数搭配列表推导式可以保留处空格

4.使用replace（）方法可以将不必要的内容替换掉

5.直接使用列表推导式也可以清除空格

6.利用字符串的切片操作可以保留需要的内容

7.直接使用split方法可以将需要的内容装到列表里

代码如下:


username = ' 明日科技 '
print(username.strip())
]]></description><category></category></item><item><title><![CDATA[8学习lamdba表达式]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107911337</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107911337</guid><author>pebbleren</author><pubDate>Mon, 10 Aug 2020 13:44:42 +0800</pubDate><description><![CDATA[要求：掌握lamdba表达式的用法

1.lamdba表达式可以查找出字符串里最大的数字

2.lamdba表达式可以查找出列表里最大的数值

3.lamdba表达式可以查找出元组里最长的数值

4.lamdba表达式可以按照字典的键输出值

代码：


num2 = '123454321'
print(max(num2,key=lambda x:abs(int(x))))     #x=符合条件的数，abs函数用于返回绝对值，max函数用于查找最大的数，所以绝对值最大的是5

listcar = [697]]></description><category></category></item><item><title><![CDATA[7列表排序]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107911246</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107911246</guid><author>pebbleren</author><pubDate>Mon, 10 Aug 2020 13:39:40 +0800</pubDate><description><![CDATA[要求：将列表里的内容从大到小排序输出

实现方式/用到的函数：

1.将数据内容写到一个空的列表里

2.将排序前的列表输出出来

3.运用sorth函数或者lamdba表达式排序

4.将排序后的列表输出出来

代码如下：


list=[{'name':'无语','python':99,'c':89},
      {'name':'wgh','python':100,'c':80},
      {'name':'琦琦','python':95,'c':97},
      {'name':'明日',]]></description><category></category></item><item><title><![CDATA[5检索敏感词]]></title><link>https://blog.youkuaiyun.com/pebbleren/article/details/107894384</link><guid>https://blog.youkuaiyun.com/pebbleren/article/details/107894384</guid><author>pebbleren</author><pubDate>Sun, 09 Aug 2020 15:29:45 +0800</pubDate><description><![CDATA[要求：检测出一个句子里有没有敏感词，如果有，将敏感词出现的次数打印出来，并将句子有敏感词的地方描红并输出。

实现方式/用到的函数：

1.创建一个列表，里面写入 敏感词

2.
]]></description><category></category></item></channel></rss>