Open jcyrss opened 4 years ago
inputStr = input('Please input student age info:')
studentInfo = inputStr.split(';')
for one in studentInfo:
# check if it is valid input
if ',' not in one:
continue
name,age = one.split(',')
name = name.strip()
age = age.strip()
# check is age digit
if not age.isdigit():
continue
age = int(age)
print('%-20s : %02d' % (name, age))
# print('{:20} : {:02}'.format(name, age))
# print(f'{name:20} : {age:02}')
ffmpeg是一个处理视频的工具软件,从下面网盘地址下载。
链接:https://pan.baidu.com/s/176Z3Cu5mlsqx1lozXFI4aQ 提取码:gwde
只要执行如下命令 ,即可将视频中的声音进行变声
ffmpeg.exe -i in.mp4 -af asetrate=44100*8.9/10,atempo=10/8.9 -c:v copy out.mp4
其中 in.mp4
替换为 输入视频文件名, out.mp4
替换为输出视频文件名。
请写一个程序,在程序开头可以定义一个变量,包含一批视频文件名,如下,该程序可以批量将这批文件中所有的视频进行变声
videoFiles = '''
bandicam 2020-01-06 11-00-45-494.mp4
bandicam 2020-01-06 11-01-35-020.mp4
bandicam 2020-01-06 11-05-11-334.mp4
'''
可以点击这里打开百度网盘 ,下载一批视频文件进行变声处理
>java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
# 参数是学生的次序号
def getStudentInfo(studentNo):
height = input('请输入学生' + str(studentNo) + '的身高:')
weight = input('请输入学生' + str(studentNo) + '的体重:')
# 注意返回的是元组
return int(height),int(weight)
# 注意,元组可以 多重赋值
height1,weight1 = getStudentInfo(1)
height2,weight2 = getStudentInfo(2)
height3,weight3 = getStudentInfo(3)
print('平均身高是' + str((height1+height2+height3)/3))
print('平均体重是' + str((weight1+weight2+weight3)/3))
import xlrd,openpyxl,json
print('打开表格...',end='')
srcBook = xlrd.open_workbook("数据.xlsx")
print('ok')
sheet = srcBook.sheet_by_index(1)
# 产品购买量表
pid2count = {}
# 读入数据
for row in range(sheet.nrows):
# 首行是 标题,要去掉
if row == 0:
continue
pid = sheet.cell_value(rowx=row,colx=11)
if pid not in pid2count:
pid2count[pid] = 1
else:
pid2count[pid] += 1
# 再读入 产品名称表
pid2pname = {}
sheet = srcBook.sheet_by_index(2)
# 读入数据
for row in range(sheet.nrows):
# 首行是 标题,要去掉
if row == 0:
continue
pid = sheet.cell_value(rowx=row,colx=0)
name = sheet.cell_value(rowx=row,colx=1)
pid2pname[pid] = name
# 产生产品名称 购买数量表
pname2count = { pid2pname[k]:v for k,v in pid2count.items()}
print(pname2count)
# 产生图表
import matplotlib.pyplot as plt
# 设定字体为微软雅黑
plt.rcParams['font.family'] = 'Microsoft Yahei'
# x刻度垂直,否则字太长了
plt.xticks(rotation=-90)
# 加长底部空间,否则文字显示不全
plt.subplots_adjust(bottom=0.45)
pnames = []
counts = []
# 排序
for p,c in sorted(pname2count.items(), key=lambda x:x[1], reverse=True):
pnames.append(p)
counts.append(c)
plt.bar(pnames, counts)
plt.show()
import requests,math,xlrd
# 百度
baidu_ak= 'xxxxxxxx'
def getGpsPointByBaiduMap(city,address):
url = f'http://api.map.baidu.com/geocoding/v3/?city={city}&address={address}&output=json&ak={baidu_ak}'
ret = requests.get(url)
retObj = ret.json()
if retObj['status'] != 0:
return None
location = retObj['result']['location']
return location['lat'],location['lng']
def haversine(coord1, coord2):
R = 6372800 # Earth radius in meters
lat1, lon1 = coord1
lat2, lon2 = coord2
phi1, phi2 = math.radians(lat1), math.radians(lat2)
dphi = math.radians(lat2 - lat1)
dlambda = math.radians(lon2 - lon1)
a = math.sin(dphi / 2) ** 2 + \
math.cos(phi1) * math.cos(phi2) * math.sin(dlambda / 2) ** 2
return 2 * R * math.atan2(math.sqrt(a), math.sqrt(1 - a))
addr1 = '省中医院'
addr2 = '江宁同仁医院'
addr2point = {}
totalDistance1 = 0
totalDistance2 = 0
targetPoint1 = getGpsPointByBaiduMap('南京', addr1)
targetPoint2 = getGpsPointByBaiduMap('南京', addr2)
def calcOneAddr(addr):
global totalDistance1,totalDistance2
if addr in addr2point:
print('地址坐标已经获取过')
point = addr2point[addr]
else:
point = getGpsPointByBaiduMap('南京', addr)
if not point:
print(f'{addr} 无法获取坐标经纬度!!')
return
totalDistance1 += haversine(point, targetPoint1)//1000
totalDistance2 += haversine(point, targetPoint2)//1000
print('打开表格...',end='')
srcBook = xlrd.open_workbook("数据.xlsx")
print('ok')
sheet = srcBook.sheet_by_index(1)
for row in range(sheet.nrows):
# 首行是 标题,要去掉
if row == 0:
continue
rlist = sheet.row_values(rowx=row)
addr = rlist[-1]
calcOneAddr(addr)
print(f'{addr1} 总距离:{totalDistance1}')
print(f'{addr2} 总距离:{totalDistance2}')
点击链接下载 数据文件包 stock.zip
解压后得到的是一个股票代码文件,记录了中国所有的股票名称和代码。
请写一个股票信息查询程序,从文件加载数据, 并且显示 ‘请输入要查询的股票名称或代码:’
当用户输入股票代码(6位全是数字)时,打印出对应的
股票名称和代码
, 当用户输入股票名称(不全是数字)时,打印出对应的股票名称和代码
,