首页 文章 精选 留言 我的

精选列表

搜索[批量导入手机通讯录],共10010篇文章
优秀的个人博客,低调大师

PHP执行批量mysql语句

当有多条mysql语句连起来需要执行,比如 $sqls= “insert table a values(1,2); insert table a values(2,3);” 需要执行的话php中可以使用的方法有三个: mysql_query pdo mysqli 三种方法当sqls语句没有问题的时候都是可以的。 但是 当sql语句是错误的时候会出现问题 第一条sql错误:三个方法都返回false 第一条sql正确,第二条sql错误:mysql_query、pdo、 mysqli:query也是返回true。所以这个时候你是没法判断你的sqls是否有那条语句是错误的。 解决这种办法有几个招: 1 解析sql语句 将每条sql都拆分开来执行。这样每个语句分开执行就解决了。但是这种方法多出了好几种方法,所以不可取。 2 将sqls语句保存为文本 使用cmd执行命令 mysql…. .< sqls.sql, 然后捕获输出。这也是一种方法,但是感觉是绕着问题走,应该还有更好的方法。 3 使用mysqli::multi_query方法 这个方法可以执行多条sql语句,然后使用mysqli::next_result来设置sql的偏移量,使用mysqli::error获取当前偏移的sql的错误状态 下面是第三种方法的示例代码 代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $sql = Config::get( 'sql' ); $content = file_get_contents ( $sql ); $config = Config::get( 'config' ) $mysqli = mysqli_connect( $config [ 'host' ], $config [ 'user' ], $config [ 'password' ], $config [ 'dbname' ]); $ret = $mysqli ->multi_query( $content ); if ( $ret === false) { echo mysqli_error( $mysqli ); } while (mysqli_more_results( $mysqli )) { if (mysqli_next_result( $mysqli ) === false) { echo mysqli_error( $mysqli ); echo "\r\n" ; break ; } } $mysqli ->close(); 这样的话当sqls语句中任意一条有错误的话,程序就会跳出这个错误。 如果你要编写初始化mysql的脚本的话,这招就非常好用了。 本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/archive/2012/11/06/2757052.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

ios 开发,通讯录信息调用常用方法,这个比较全,不用再整理了

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 ABAddressBookRef addressBook = ABAddressBookCreate(); CFArrayRef results = ABAddressBookCopyArrayOfAllPeople(addressBook); for ( int i = 0; i < CFArrayGetCount(results); i++) { ABRecordRef person = CFArrayGetValueAtIndex(results, i); //读取firstname NSString *personName = ( NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); if (personName != nil ) textView.text = [textView.text stringByAppendingFormat:@ "\n姓名:%@\n" ,personName]; //读取lastname NSString *lastname = ( NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); if (lastname != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,lastname]; //读取middlename NSString *middlename = ( NSString *)ABRecordCopyValue(person, kABPersonMiddleNameProperty); if (middlename != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,middlename]; //读取prefix前缀 NSString *prefix = ( NSString *)ABRecordCopyValue(person, kABPersonPrefixProperty); if (prefix != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,prefix]; //读取suffix后缀 NSString *suffix = ( NSString *)ABRecordCopyValue(person, kABPers*****uffixProperty); if (suffix != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,suffix]; //读取nickname呢称 NSString *nickname = ( NSString *)ABRecordCopyValue(person, kABPersonNicknameProperty); if (nickname != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,nickname]; //读取firstname拼音音标 NSString *firstnamePhonetic = ( NSString *)ABRecordCopyValue(person, kABPersonFirstNamePhoneticProperty); if (firstnamePhonetic != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,firstnamePhonetic]; //读取lastname拼音音标 NSString *lastnamePhonetic = ( NSString *)ABRecordCopyValue(person, kABPersonLastNamePhoneticProperty); if (lastnamePhonetic != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,lastnamePhonetic]; //读取middlename拼音音标 NSString *middlenamePhonetic = ( NSString *)ABRecordCopyValue(person, kABPersonMiddleNamePhoneticProperty); if (middlenamePhonetic != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,middlenamePhonetic]; //读取organization公司 NSString *organization = ( NSString *)ABRecordCopyValue(person, kABPersonOrganizationProperty); if (organization != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,organization]; //读取jobtitle工作 NSString *jobtitle = ( NSString *)ABRecordCopyValue(person, kABPersonJobTitleProperty); if (jobtitle != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,jobtitle]; //读取department部门 NSString *department = ( NSString *)ABRecordCopyValue(person, kABPersonDepartmentProperty); if (department != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,department]; //读取birthday生日 NSDate *birthday = ( NSDate *)ABRecordCopyValue(person, kABPersonBirthdayProperty); if (birthday != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,birthday]; //读取note备忘录 NSString *note = ( NSString *)ABRecordCopyValue(person, kABPersonNoteProperty); if (note != nil ) textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,note]; //第一次添加该条记录的时间 NSString *firstknow = ( NSString *)ABRecordCopyValue(person, kABPersonCreationDateProperty); NSLog (@ "第一次添加该条记录的时间%@\n" ,firstknow); //最后一次修改該条记录的时间 NSString *lastknow = ( NSString *)ABRecordCopyValue(person, kABPersonModificationDateProperty); NSLog (@ "最后一次修改該条记录的时间%@\n" ,lastknow); //获取email多值 ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty); int emailcount = ABMultiValueGetCount(email); for ( int x = 0; x < emailcount; x++) { //获取email Label NSString * emailLabel = ( NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(email, x)); //获取email值 NSString * emailContent = ( NSString *)ABMultiValueCopyValueAtIndex(email, x); textView.text = [textView.text stringByAppendingFormat:@ "%@:%@\n" ,emailLabel,emailContent]; } //读取地址多值 ABMultiValueRef address = ABRecordCopyValue(person, kABPersonAddressProperty); int count = ABMultiValueGetCount(address); for ( int j = 0; j < count; j++) { //获取地址Label NSString * addressLabel = ( NSString *)ABMultiValueCopyLabelAtIndex(address, j); textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,addressLabel]; //获取該label下的地址6属性 NSDictionary * personaddress =( NSDictionary *) ABMultiValueCopyValueAtIndex(address, j); NSString * country = [personaddress valueForKey:( NSString *)kABPersonAddressCountryKey]; if (country != nil ) textView.text = [textView.text stringByAppendingFormat:@ "国家:%@\n" ,country]; NSString * city = [personaddress valueForKey:( NSString *)kABPersonAddressCityKey]; if (city != nil ) textView.text = [textView.text stringByAppendingFormat:@ "城市:%@\n" ,city]; NSString * state = [personaddress valueForKey:( NSString *)kABPersonAddressStateKey]; if (state != nil ) textView.text = [textView.text stringByAppendingFormat:@ "省:%@\n" ,state]; NSString * street = [personaddress valueForKey:( NSString *)kABPersonAddressStreetKey]; if (street != nil ) textView.text = [textView.text stringByAppendingFormat:@ "街道:%@\n" ,street]; NSString * zip = [personaddress valueForKey:( NSString *)kABPersonAddressZIPKey]; if (zip != nil ) textView.text = [textView.text stringByAppendingFormat:@ "邮编:%@\n" ,zip]; NSString * coutntrycode = [personaddress valueForKey:( NSString *)kABPersonAddressCountryCodeKey]; if (coutntrycode != nil ) textView.text = [textView.text stringByAppendingFormat:@ "国家编号:%@\n" ,coutntrycode]; } //获取dates多值 ABMultiValueRef dates = ABRecordCopyValue(person, kABPersonDateProperty); int datescount = ABMultiValueGetCount(dates); for ( int y = 0; y < datescount; y++) { //获取dates Label NSString * datesLabel = ( NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(dates, y)); //获取dates值 NSString * datesContent = ( NSString *)ABMultiValueCopyValueAtIndex(dates, y); textView.text = [textView.text stringByAppendingFormat:@ "%@:%@\n" ,datesLabel,datesContent]; } //获取kind值 CFNumberRef recordType = ABRecordCopyValue(person, kABPersonKindProperty); if (recordType == kABPersonKindOrganization) { // it's a company NSLog (@ "it's a company\n" ); } else { // it's a person, resource, or room NSLog (@ "it's a person, resource, or room\n" ); } //获取IM多值 ABMultiValueRef instantMessage = ABRecordCopyValue(person, kABPersonInstantMessageProperty); for ( int l = 1; l < ABMultiValueGetCount(instantMessage); l++) { //获取IM Label NSString * instantMessageLabel = ( NSString *)ABMultiValueCopyLabelAtIndex(instantMessage, l); textView.text = [textView.text stringByAppendingFormat:@ "%@\n" ,instantMessageLabel]; //获取該label下的2属性 NSDictionary * instantMessageContent =( NSDictionary *) ABMultiValueCopyValueAtIndex(instantMessage, l); NSString * username = [instantMessageContent valueForKey:( NSString *)kABPersonInstantMessageUsernameKey]; if (username != nil ) textView.text = [textView.text stringByAppendingFormat:@ "username:%@\n" ,username]; NSString * service = [instantMessageContent valueForKey:( NSString *)kABPersonInstantMessageServiceKey]; if (service != nil ) textView.text = [textView.text stringByAppendingFormat:@ "service:%@\n" ,service]; } //读取电话多值 ABMultiValueRef phone = ABRecordCopyValue(person, kABPersonPhoneProperty); for ( int k = 0; k<ABMultiValueGetCount(phone); k++) { //获取电话Label NSString * personPhoneLabel = ( NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(phone, k)); //获取該Label下的电话值 NSString * personPhone = ( NSString *)ABMultiValueCopyValueAtIndex(phone, k); textView.text = [textView.text stringByAppendingFormat:@ "%@:%@\n" ,personPhoneLabel,personPhone]; } //获取URL多值 ABMultiValueRef url = ABRecordCopyValue(person, kABPersonURLProperty); for ( int m = 0; m < ABMultiValueGetCount(url); m++) { //获取电话Label NSString * urlLabel = ( NSString *)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(url, m)); //获取該Label下的电话值 NSString * urlContent = ( NSString *)ABMultiValueCopyValueAtIndex(url,m); textView.text = [textView.text stringByAppendingFormat:@ "%@:%@\n" ,urlLabel,urlContent]; } //读取照片 NSData *image = ( NSData *)ABPersonCopyImageData(person); UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(200, 0, 50, 50)]; [myImage setImage:[UIImage imageWithData:image]]; myImage.opaque = YES ; [textView addSubview:myImage]; } CFRelease(results); CFRelease(addressBook); 本文转自夏雪冬日博客园博客,原文链接:http://www.cnblogs.com/heyonggang/p/3472867.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

python多进程批量读取图片以及对图片批量旋转等数据增强

深度学习里面最重要的是数据,而有时候数据很少,又或者样本不均衡等问题,这时候就需要对图像进行一系列的数据增强,旋转就是常用的数据增强方式.至于python如何对图像旋转,在之前的文章就有所介绍, python对图像旋转显示等 这里不详细细谈,一般直接想到的就是添加一个循环,按照循序读取图片,如果图片只有几千张,那可能值耗费几十分钟,但如果图像有上百万张,那么就需要耗费一天,甚至更多的时间,这时候就需要多进程来实现,python多进程虽然比不上c++等其他语言,但是python胜在方便,同样也能缩小很长的时间,本文的例子主要是用multiprocessing这个库. 直接看代码 [python] view plain copy #coding=utf-8 ''''' #==================== #测试一下进程 #==================== ''' frommultiprocessingimportPool importscipy fromscipyimportmisc importos importtime importglob fromscipyimportndimage start=time.time() defget_image_paths(folder):#这个函数的作用的获取文件的列表,注释部分是获取 #return(os.path.join(folder,f) #forfinos.listdir(folder) #if'png'inf) returnglob.glob(os.path.join(folder,'*.png')) defcreate_read_img(filename): im=misc.imread(filename)#读取图像 img_rote=ndimage.rotate(im,90)#旋转90度 #scipy.misc.imsave('...',img_rote) img_path='存放图像的目录/' imgs=get_image_paths(img_path) printimgs pool=Pool() pool.map(create_read_img,imgs) pool.close() pool.join() #foriinimgs: #create_read_img(i)这部分是循环,可以用来对比时间 end=time.time() printend-start from: http://blog.csdn.net/hjxu2016/article/details/79536129

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册