IOS 获取手机设备信息

Wesley13
• 阅读 788

回顾一下,Android中获取手机设备相关信息:通过android.os.Build、context.getResources().getDisplayMetrics()、Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)、(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)等等,从而获取到手机设备:手机型号、手机品牌、设备名、手机系统、屏幕宽高等等一系列信息,其中还涉及到权限问题。

相对IOS,则是从开发库中获取设备相关信息:通过UIDevice、NSLocale、UIScreen、CTTelephonyNetworkInfo等等,从而获取到手机设备:设备名称、系统名称、系统版本、屏幕宽高等等一系列信息,但需要通过指定的开发库才能获取得到。

此处需要导入部分开发库:

#import <sys/utsname.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <SystemConfiguration/CaptiveNetwork.h>
#import <NetworkExtension/NetworkExtension.h>

DeviceInfo.h

#import <UIKit/UIKit.h>
#import <sys/utsname.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <SystemConfiguration/CaptiveNetwork.h>
#import <NetworkExtension/NetworkExtension.h>
@class DeviceInfo;

#define DUMMY_MAC_ADDR  @"02:00:00:00:00:00"

/**
 * 设备相关信息
 **/
@interface DeviceInfo : NSObject

/**
 * 设备名称
 **/
@property (nonatomic, strong) NSString *deviceName;

/**
 * 系统名称
 **/
@property (nonatomic, strong) NSString *systemName;

/**
 * 系统版本
 **/
@property (nonatomic, strong) NSString *systemVersion;

/**
 * 设备模式
 **/
@property (nonatomic, strong) NSString *model;

/**
 * 本地设备模式
 **/
@property (nonatomic, strong) NSString *localizedModel;

/**
 * 系统语言
 **/
@property (nonatomic, strong) NSString *language;

/**
 * 国家
 **/
@property (nonatomic, strong) NSString *country;

/**
 * IDFV
 **/
@property (nonatomic, strong) NSString *deviceIDFV;

/**
 * 屏幕宽度
 **/
@property (nonatomic) int width;

/**
 * 屏幕高度
 **/
@property (nonatomic) int height;

/**
 * 屏幕宽度分辨率
 **/
@property (nonatomic) int screenWidth;

/**
 * 屏幕高度分辨率
 **/
@property (nonatomic) int screenHeight;

/**
 * 运营商
 **/
@property (nonatomic, strong) NSString *carrierName;

/**
 * mac
 **/
@property (nonatomic, strong) NSString *mac;

@end

DeviceInfo.m

#import <Foundation/Foundation.h>
#import "DeviceInfo.h"

@implementation DeviceInfo

- (NSString *)deviceName{
    NSString *dName = [[UIDevice currentDevice] name];
    if (dName) {
        return dName;
    }
    return @"";
}

- (NSString *)systemName{
    NSString *sName = [[UIDevice currentDevice] systemName];
    if (sName) {
        return sName;
    }
    return @"";
}

- (NSString *)systemVersion{
    NSString *sVersion = [[UIDevice currentDevice] systemVersion];
    if (sVersion) {
        return sVersion;
    }
    return @"";
}

- (NSString *)model{
//    NSString *mod = [[UIDevice currentDevice] model];
//    if (mod) {
//        return mod;
//    }
    
    struct utsname systemInfo;
    uname(&systemInfo);
    
    NSString *deviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
    
    if (!deviceModel) {
        return @"";
    }
    
    if ([deviceModel isEqualToString:@"iPhone3,1"])    return @"iPhone 4";
    if ([deviceModel isEqualToString:@"iPhone3,2"])    return @"iPhone 4";
    if ([deviceModel isEqualToString:@"iPhone3,3"])    return @"iPhone 4";
    if ([deviceModel isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
    if ([deviceModel isEqualToString:@"iPhone5,1"])    return @"iPhone 5";
    if ([deviceModel isEqualToString:@"iPhone5,2"])    return @"iPhone 5 (GSM+CDMA)";
    if ([deviceModel isEqualToString:@"iPhone5,3"])    return @"iPhone 5c (GSM)";
    if ([deviceModel isEqualToString:@"iPhone5,4"])    return @"iPhone 5c (GSM+CDMA)";
    if ([deviceModel isEqualToString:@"iPhone6,1"])    return @"iPhone 5s (GSM)";
    if ([deviceModel isEqualToString:@"iPhone6,2"])    return @"iPhone 5s (GSM+CDMA)";
    if ([deviceModel isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
    if ([deviceModel isEqualToString:@"iPhone7,2"])    return @"iPhone 6";
    if ([deviceModel isEqualToString:@"iPhone8,1"])    return @"iPhone 6s";
    if ([deviceModel isEqualToString:@"iPhone8,2"])    return @"iPhone 6s Plus";
    if ([deviceModel isEqualToString:@"iPhone8,4"])    return @"iPhone SE";
    // 日行两款手机型号均为日本独占,可能使用索尼FeliCa支付方案而不是苹果支付
    if ([deviceModel isEqualToString:@"iPhone9,1"])    return @"iPhone 7";
    if ([deviceModel isEqualToString:@"iPhone9,2"])    return @"iPhone 7 Plus";
    if ([deviceModel isEqualToString:@"iPhone9,3"])    return @"iPhone 7";
    if ([deviceModel isEqualToString:@"iPhone9,4"])    return @"iPhone 7 Plus";
    if ([deviceModel isEqualToString:@"iPhone10,1"])   return @"iPhone_8";
    if ([deviceModel isEqualToString:@"iPhone10,4"])   return @"iPhone_8";
    if ([deviceModel isEqualToString:@"iPhone10,2"])   return @"iPhone_8_Plus";
    if ([deviceModel isEqualToString:@"iPhone10,5"])   return @"iPhone_8_Plus";
    if ([deviceModel isEqualToString:@"iPhone10,3"])   return @"iPhone X";
    if ([deviceModel isEqualToString:@"iPhone10,6"])   return @"iPhone X";
    if ([deviceModel isEqualToString:@"iPhone11,8"])   return @"iPhone XR";
    if ([deviceModel isEqualToString:@"iPhone11,2"])   return @"iPhone XS";
    if ([deviceModel isEqualToString:@"iPhone11,6"])   return @"iPhone XS Max";
    if ([deviceModel isEqualToString:@"iPhone11,4"])   return @"iPhone XS Max";
    if ([deviceModel isEqualToString:@"iPhone12,1"])   return @"iPhone 11";
    if ([deviceModel isEqualToString:@"iPhone12,3"])   return @"iPhone 11 Pro";
    if ([deviceModel isEqualToString:@"iPhone12,5"])   return @"iPhone 11 Pro Max";
    if ([deviceModel isEqualToString:@"iPhone12,8"])   return @"iPhone SE2";

    if ([deviceModel isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";
    if ([deviceModel isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";
    if ([deviceModel isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";
    if ([deviceModel isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";
    if ([deviceModel isEqualToString:@"iPod5,1"])      return @"iPod Touch (5 Gen)";
    if ([deviceModel isEqualToString:@"iPod7,1"])      return @"iPod Touch (6 Gen)";
    if ([deviceModel isEqualToString:@"iPod9,1"])      return @"iPod Touch (7 Gen)";
    if ([deviceModel isEqualToString:@"iPad1,1"])      return @"iPad";
    if ([deviceModel isEqualToString:@"iPad1,2"])      return @"iPad 3G";
    if ([deviceModel isEqualToString:@"iPad2,1"])      return @"iPad 2 (WiFi)";
    if ([deviceModel isEqualToString:@"iPad2,2"])      return @"iPad 2";
    if ([deviceModel isEqualToString:@"iPad2,3"])      return @"iPad 2 (CDMA)";
    if ([deviceModel isEqualToString:@"iPad2,4"])      return @"iPad 2";
    if ([deviceModel isEqualToString:@"iPad2,5"])      return @"iPad Mini (WiFi)";
    if ([deviceModel isEqualToString:@"iPad2,6"])      return @"iPad Mini";
    if ([deviceModel isEqualToString:@"iPad2,7"])      return @"iPad Mini (GSM+CDMA)";
    if ([deviceModel isEqualToString:@"iPad3,1"])      return @"iPad 3 (WiFi)";
    if ([deviceModel isEqualToString:@"iPad3,2"])      return @"iPad 3 (GSM+CDMA)";
    if ([deviceModel isEqualToString:@"iPad3,3"])      return @"iPad 3";
    if ([deviceModel isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";
    if ([deviceModel isEqualToString:@"iPad3,5"])      return @"iPad 4";
    if ([deviceModel isEqualToString:@"iPad3,6"])      return @"iPad 4 (GSM+CDMA)";
    if ([deviceModel isEqualToString:@"iPad4,1"])      return @"iPad Air (WiFi)";
    if ([deviceModel isEqualToString:@"iPad4,2"])      return @"iPad Air (Cellular)";
    if ([deviceModel isEqualToString:@"iPad4,4"])      return @"iPad Mini 2 (WiFi)";
    if ([deviceModel isEqualToString:@"iPad4,5"])      return @"iPad Mini 2 (Cellular)";
    if ([deviceModel isEqualToString:@"iPad4,6"])      return @"iPad Mini 2";
    if ([deviceModel isEqualToString:@"iPad4,7"])      return @"iPad Mini 3";
    if ([deviceModel isEqualToString:@"iPad4,8"])      return @"iPad Mini 3";
    if ([deviceModel isEqualToString:@"iPad4,9"])      return @"iPad Mini 3";
    if ([deviceModel isEqualToString:@"iPad5,1"])      return @"iPad Mini 4 (WiFi)";
    if ([deviceModel isEqualToString:@"iPad5,2"])      return @"iPad Mini 4 (LTE)";
    if ([deviceModel isEqualToString:@"iPad5,3"])      return @"iPad Air 2";
    if ([deviceModel isEqualToString:@"iPad5,4"])      return @"iPad Air 2";
    if ([deviceModel isEqualToString:@"iPad6,3"])      return @"iPad Pro 9.7";
    if ([deviceModel isEqualToString:@"iPad6,4"])      return @"iPad Pro 9.7";
    if ([deviceModel isEqualToString:@"iPad6,7"])      return @"iPad Pro 12.9";
    if ([deviceModel isEqualToString:@"iPad6,8"])      return @"iPad Pro 12.9";
    if ([deviceModel isEqualToString:@"iPad6,11"])      return @"iPad (5 Gen)";
    if ([deviceModel isEqualToString:@"iPad6,12"])      return @"iPad (5 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,5"])      return @"iPad (6 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,6"])      return @"iPad (6 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,11"])      return @"iPad (7 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,12"])      return @"iPad (7 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,1"])      return @"iPad Pro 12.9 (2 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,2"])      return @"iPad Pro 12.9 (2 Gen)";
    if ([deviceModel isEqualToString:@"iPad7,3"])      return @"iPad Pro 10.5";
    if ([deviceModel isEqualToString:@"iPad7,4"])      return @"iPad Pro 10.5";
    if ([deviceModel isEqualToString:@"iPad8,1"])      return @"iPad Pro 11";
    if ([deviceModel isEqualToString:@"iPad8,2"])      return @"iPad Pro 11";
    if ([deviceModel isEqualToString:@"iPad8,3"])      return @"iPad Pro 11";
    if ([deviceModel isEqualToString:@"iPad8,4"])      return @"iPad Pro 11";
    if ([deviceModel isEqualToString:@"iPad8.5"])      return @"iPad Pro 12.9 (3 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.6"])      return @"iPad Pro 12.9 (3 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.7"])      return @"iPad Pro 12.9 (3 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.8"])      return @"iPad Pro 12.9 (3 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.9"])      return @"iPad Pro 11 (2 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.10"])      return @"iPad Pro 11 (2 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.11"])      return @"iPad Pro 12.9 (4 Gen)";
    if ([deviceModel isEqualToString:@"iPad8.12"])      return @"iPad Pro 12.9 (4 Gen)";
    if ([deviceModel isEqualToString:@"iPad11,1"])      return @"iPad Mini (5 Gen)";
    if ([deviceModel isEqualToString:@"iPad11,2"])      return @"iPad Mini (5 Gen)";
    if ([deviceModel isEqualToString:@"iPad11,3"])      return @"iPad Air (3 Gen)";
    if ([deviceModel isEqualToString:@"iPad11,4"])      return @"iPad Air (3 Gen)";
    if ([deviceModel isEqualToString:@"iPad11,6"])      return @"iPad (8 Gen)";
    if ([deviceModel isEqualToString:@"iPad11,7"])      return @"iPad (8 Gen)";
    if ([deviceModel isEqualToString:@"iPad13,1"])      return @"iPad Air (4 Gen)";
    if ([deviceModel isEqualToString:@"iPad13,2"])      return @"iPad Air (4 Gen)";

    if ([deviceModel isEqualToString:@"Watch1,1"])      return @"Apple Watch 1";
    if ([deviceModel isEqualToString:@"Watch1,2"])      return @"Apple Watch 1";
    if ([deviceModel isEqualToString:@"Watch2,3"])      return @"Apple Watch Series 2";
    if ([deviceModel isEqualToString:@"Watch2,4"])      return @"Apple Watch Series 2";
    if ([deviceModel isEqualToString:@"Watch2,6"])      return @"Apple Watch Series 1";
    if ([deviceModel isEqualToString:@"Watch2,7"])      return @"Apple Watch Series 1";
    if ([deviceModel isEqualToString:@"Watch3,1"])      return @"Apple Watch Series 3";
    if ([deviceModel isEqualToString:@"Watch3,2"])      return @"Apple Watch Series 3";
    if ([deviceModel isEqualToString:@"Watch3,3"])      return @"Apple Watch Series 3";
    if ([deviceModel isEqualToString:@"Watch3,4"])      return @"Apple Watch Series 3";
    if ([deviceModel isEqualToString:@"Watch4,1"])      return @"Apple Watch Series 4";
    if ([deviceModel isEqualToString:@"Watch4,2"])      return @"Apple Watch Series 4";
    if ([deviceModel isEqualToString:@"Watch4,3"])      return @"Apple Watch Series 4";
    if ([deviceModel isEqualToString:@"Watch4,4"])      return @"Apple Watch Series 4";
    if ([deviceModel isEqualToString:@"Watch5,1"])      return @"Apple Watch Series 5";
    if ([deviceModel isEqualToString:@"Watch5,2"])      return @"Apple Watch Series 5";
    if ([deviceModel isEqualToString:@"Watch5,3"])      return @"Apple Watch Series 5";
    if ([deviceModel isEqualToString:@"Watch5,4"])      return @"Apple Watch Series 5";
    if ([deviceModel isEqualToString:@"Watch5,9"])      return @"Apple Watch SE";
    if ([deviceModel isEqualToString:@"Watch5,10"])      return @"Apple Watch SE";
    if ([deviceModel isEqualToString:@"Watch5,11"])      return @"Apple Watch SE";
    if ([deviceModel isEqualToString:@"Watch5,12"])      return @"Apple Watch SE";
    if ([deviceModel isEqualToString:@"Watch6,1"])      return @"Apple Watch Series 6";
    if ([deviceModel isEqualToString:@"Watch6,2"])      return @"Apple Watch Series 6";
    if ([deviceModel isEqualToString:@"Watch6,3"])      return @"Apple Watch Series 6";
    if ([deviceModel isEqualToString:@"Watch6,4"])      return @"Apple Watch Series 6";

    if ([deviceModel isEqualToString:@"AppleTV1,1"])      return @"Apple TV 1";
    if ([deviceModel isEqualToString:@"AppleTV2,1"])      return @"Apple TV 2";
    if ([deviceModel isEqualToString:@"AppleTV3,1"])      return @"Apple TV 3";
    if ([deviceModel isEqualToString:@"AppleTV3,2"])      return @"Apple TV 3";
    if ([deviceModel isEqualToString:@"AppleTV5,3"])      return @"Apple TV 4";
    if ([deviceModel isEqualToString:@"AppleTV6,2"])      return @"Apple TV 4K";

    if ([deviceModel isEqualToString:@"AirPods1,1"])      return @"AirPods 1";
    if ([deviceModel isEqualToString:@"AirPods2,1"])      return @"AirPods 2";
    if ([deviceModel isEqualToString:@"iProd8,1"])      return @"AirPods Pro";

    if ([deviceModel isEqualToString:@"AudioAccessory1,1"])      return @"HomePod";
    if ([deviceModel isEqualToString:@"AudioAccessory1,2"])      return @"HomePod";

    if ([deviceModel isEqualToString:@"i386"])         return @"Simulator";
    if ([deviceModel isEqualToString:@"x86_64"])       return @"Simulator";
    return deviceModel;
}

- (NSString *)localizedModel{
    NSString *localModel = [[UIDevice currentDevice] localizedModel];
    if (localModel) {
        return localModel;
    }
    return @"";
}

- (NSString *)language{
    NSArray *languageArray = [NSLocale preferredLanguages];
    NSString *language = [languageArray objectAtIndex:0];
    if (language) {
        return language;
    }
    return @"";
}

- (NSString *)country{
    NSLocale *locale = [NSLocale currentLocale];
    NSString *country = [locale localeIdentifier];
    if (country) {
        return country;
    }
    return @"";
}

- (NSString *)deviceIDFV{
    NSUUID *idfvUUID = [[UIDevice currentDevice] identifierForVendor];
    if (idfvUUID) {
        NSString *idfv = [idfvUUID UUIDString];
        if (idfv) {
            return idfv;
        }
    }
    return @"";
}

- (int)width{
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize size = rect.size;
    CGFloat width = size.width;
    int widthInt = [[NSNumber numberWithFloat:width] intValue];
    if (widthInt) {
        return widthInt;
    }
    return 0;
}

- (int)height{
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize size = rect.size;
    CGFloat height = size.height;
    int heightInt = [[NSNumber numberWithFloat:height] intValue];
    if (heightInt) {
        return heightInt;
    }
    return 0;
}

- (int)screenWidth{
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize size = rect.size;
    CGFloat scale_screen = [UIScreen mainScreen].scale;
    int screenWidthInt = [[NSNumber numberWithFloat:size.width * scale_screen] intValue];
    if (screenWidthInt) {
        return screenWidthInt;
    }
    return 0;
}

- (int)screenHeight{
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize size = rect.size;
    CGFloat scale_screen = [UIScreen mainScreen].scale;
    int screenHeightInt = [[NSNumber numberWithFloat:size.height * scale_screen] intValue];
    if (screenHeightInt) {
        return screenHeightInt;
    }
    return 0;
}

- (NSString *)carrierName{
    CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier *carrier = info.subscriberCellularProvider;
    if(carrier.carrierName) {
        return carrier.carrierName;
    }
    return @"";
}

- (NSString *)mac{
    NSArray*wfMac=CFBridgingRelease(CNCopySupportedInterfaces());
    id info1 = nil;
    for (NSString *macName in wfMac) {
        info1 = (__bridge_transfer id)CNCopyCurrentNetworkInfo((CFStringRef) macName);
        if (info1 && [info1 count]) {
            break;
        }
    }
    NSDictionary *dic = (NSDictionary *)info1;
    NSString *wifiMac = [dic objectForKey:@"BSSID"];
    if(wifiMac) {
        return wifiMac;
    }
    return DUMMY_MAC_ADDR;
}

@end

注:获取设备model中systemInfo.machine设备信息获取是相对较为完善且全面的,若后续有新的设备新增,请从 Models - The iPhone Wiki 上进行续补;Apple对于获取MAC相对严格控制,一般是获取不到的。

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
梦
3年前
微信小程序new Date()转换时间异常问题
微信小程序苹果手机页面上显示时间异常,安卓机正常问题image(https://imghelloworld.osscnbeijing.aliyuncs.com/imgs/b691e1230e2f15efbd81fe11ef734d4f.png)错误代码vardate'2021030617:00:00'vardateT
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这