num_int=input (‘23’) print (type(num_inp))
时间: 2023-12-11 09:02:49 浏览: 32
您输入的代码存在错误。应该是:
```
num_int = input('请输入一个整数:')
print(type(num_int))
```
这段代码的作用是让用户输入一个整数,并将其存储为字符串类型的变量 `num_int`。然后使用 `type()` 函数打印出 `num_int` 的数据类型,即 `<class 'str'>`。因为 `input()` 函数返回的是字符串类型的数据。
相关问题
解释下列每一行代码的作用inp_pose = args.pose_input_size.split('x') inp_pose = (int(inp_pose[0]), int(inp_pose[1])) pose_model = SPPE_FastPose(args.pose_backbone, inp_pose[0], inp_pose[1], device=device)
这段代码的作用是根据输入参数,创建一个姿态估计模型。
第一行代码 `inp_pose = args.pose_input_size.split('x')` 的作用是将args.pose_input_size字符串按照'x'分割成两个部分,分别存储在inp_pose列表中。通过这个操作,我们可以得到输入姿态估计模型的尺寸大小。
第二行代码 `inp_pose = (int(inp_pose[0]), int(inp_pose[1]))` 的作用是将inp_pose列表中的两个字符串转换成整数类型,得到最终的输入姿态估计模型的尺寸大小。
第三行代码 `pose_model = SPPE_FastPose(args.pose_backbone, inp_pose[0], inp_pose[1], device=device)` 的作用是根据输入的姿态估计参数和设备信息,创建一个姿态估计模型。其中,SPPE_FastPose是一个姿态估计模型的类,args.pose_backbone是指定的模型架构,inp_pose[0]和inp_pose[1]是输入的图像尺寸大小,device是设备信息。通过这个操作,我们可以得到一个可以用于姿态估计的模型对象pose_model。
综上,这段代码的作用是根据输入参数,创建一个姿态估计模型对象pose_model,用于后续的姿态估计操作。
import pandas as pd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei'] import tushare as ts import os import tushare as ts ts.set_token('bb00bf226ce5a2f24de40a18c62596d511508ecc4b83b7c62b17b86d') pro = ts.pro_api() def get_data(code,start,end): df=pro.daily(ts_code=code,autype='qfq',start_date=start,end_date=end) print(df) df.index = pd.to_datetime(df.trade_date) #设置把日期作为索引 #df['ma'] = 0.0 # Backtrader需要用到 #df['openinterest'] = 0.0 # Backtrader需要用到 #定义两个新的列ma和openinterest df = df[['open', 'high', 'low', 'close', 'vol']] #重新设置df取值,并返回df return df def acquire_code(): #只下载一只股票数据,且只用CSV保存 未来可以有自己的数据库 inp_code =input('600893.SH') inp_start = input('2019-01-01') inp_end = input('2020-01-01') df = get_data(inp_code,inp_start,inp_end) print(df.info()) #输出统计各列的数据量 print("—"*30) #分割线 print(df.describe()) #输出常用统计参数 df.sort_index(inplace=True) #把股票数据按照时间正序排列 path = os.path.join(os.path.join(os.getcwd(), "D:\学习\AI\project\pythonProject-tushare\data"), inp_code + "yy.csv") #os.path地址拼接,''数据地址''为文件保存路径 # path = os.path.join(os.path.join(os.getcwd(),"数据地址"),inp_code+"_30M.csv") df.to_csv(path) acquire_code() 代码修正
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
import tushare as ts
import os
ts.set_token('bb00bf226ce5a2f24de40a18c62596d511508ecc4b83b7c62b17b86d')
pro = ts.pro_api()
def get_data(code,start,end):
df=pro.daily(ts_code=code,autype='qfq',start_date=start,end_date=end)
print(df)
df.index = pd.to_datetime(df.trade_date)
#设置把日期作为索引
#df['ma'] = 0.0 # Backtrader需要用到
#df['openinterest'] = 0.0 # Backtrader需要用到
#定义两个新的列ma和openinterest
df = df[['open', 'high', 'low', 'close', 'vol']]
#重新设置df取值,并返回df
return df
def acquire_code():
#只下载一只股票数据,且只用CSV保存
#未来可以有自己的数据库
inp_code =input('请输入股票代码:')
inp_start = input('请输入开始日期(如:2019-01-01):')
inp_end = input('请输入结束日期(如:2020-01-01):')
df = get_data(inp_code,inp_start,inp_end)
print(df.info())
#输出统计各列的数据量
print("-"*30)
#分割线
print(df.describe())
#输出常用统计参数
df.sort_index(inplace=True)
#把股票数据按照时间正序排列
path = os.path.join(os.path.join(os.getcwd(),"data"), inp_code + ".csv")
#os.path地址拼接,''数据地址''为文件保存路径
# path = os.path.join(os.path.join(os.getcwd(),"数据地址"),inp_code+"_30M.csv")
df.to_csv(path)
acquire_code()
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)