- '''
- @author:Mr_YJY
- @file:随机生成指定数量的手机号
- @time:2018/10/21
- '''
- '''
- 手机号是11位
- 电信:133 153 180。。。
- 联通:130 131 155。。。
- 移动:134 138 139。。。
- 第一位数:1
- 第二位数:3,4,5,7,8
- 第三位数:3:0-9
- 4:5,7,9
- 5:09,!=4
- 7:09,!=4,9
- 8:0-9
- 后8位:随机产生
- '''
-
- import random
- # 定义函数
- def creat_phone():
- # 第二位数
- second=[3,4,5,7,8][random.randint(0,4)]
- # 根据第二数获取第三位数
- third={
- 3:random.randint(0,9),
- 4:[5,7,9][random.randint(0,2)],
- 5:[i for i in range(10)if i !=4][random.randint(0,8)],
- 7:[i for i in range(10) if i not in [4,9]][random.randint(0, 7)],
- 8:random.randint(0,9)
- }[second]
- # 获取后8位数
- str_num = ''
- for i in range(8):
- index=random.randint(0,9)
- str_num=str_num+str(index)
- return '1{}{}{}'.format(second, third, str_num)
- # ba=random.randint(10000000,99999999)#简单 但缺少00000000-09999999
- # return'1{}{}{}'.format(second,third,ba)
- # 调用
- # num=creat_phone()
- # print(num)
- num=input("请输入生成的数量:")
- for index in range(0,int(num)):
- phone=creat_phone()
- print('第{}个电话号:{}'.format(index+1,phone))
- '''
- @author:Mr_YJY
- @file:整理桌面文件
- @time:2018/10/21
- '''
- import os
- import shutil
- # 桌面的路径
- desktop=os.path.join(os.path.expanduser('~'),'Desktop')
- name = input('输入整理后的文件夹的名字:')
- clean = os.path.join(desktop,name)
- # 判断文件夹是否存在(true不创建;false创建)
- idExists=os.path.exists(clean)
- if idExists == False:
- os.mkdir(clean)# 创建文件夹
- else:
- pass
-
- # 获取文件
- name_list=os.listdir(desktop)
- # 分类
- for file in name_list:
- filePath=os.path.join(desktop,file)
- if not os.path.isfile(filePath):
- continue
- elif os.path.isfile(filePath):
- # 分割文件名和拓展名
- fileExpand=os.path.splitext(file)[1]
- fileExpand=fileExpand[1:]
- # print(fileExpand)
-
- # 创建文件夹
- expand_file_name=os.path.join(clean,fileExpand)
- if not os.path.exists(expand_file_name):
- os.mkdir(expand_file_name)
- # 复制到指定路径下
- shutil.move(filePath, expand_file_name)