代码给了我一个错误..我在这里做错了什么
public static final String[] PROJECTION ={
ContactsContract.Data.MIMETYPE,
ContactsContract.Data.DATA1,
ContactsContract.Data.DATA2,
ContactsContract.Data.DATA3,
ContactsContract.Data.DATA4,
ContactsContract.Data.DATA5,
ContactsContract.Data.DATA6,
ContactsContract.Data.DATA7,
ContactsContract.Data.DATA8,
ContactsContract.Data.DATA9,
ContactsContract.Data.DATA10,
ContactsContract.Data.DATA11,
ContactsContract.Data.DATA12,
ContactsContract.Data.DATA13,
ContactsContract.Data.DATA14,
ContactsContract.Data.DATA15
};
private static final int MIMETYPE_COLUMN=0;
private static final int DATA_COLUMN=1;
private static final int DATATYPE_COLUMN=2;
private static final String SELECTION = ContactsContract.Data.CONTACT_ID + " = ?";
public static ContactWrapper localContact(long contactId){
Cursor cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI,PROJECTION, SELECTION, new String[]{String.valueOf(contactId)}, null);
ContactWrapper wrapper = new ContactWrapper(contact);
if(cursor==null){
return wrapper;
}
while(cursor.moveToNext()){
String mime=cursor.getString(MIMETYPE_COLUMN);
if (mime.equals(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)) {
contact.setU8sDisplayName(cursor.getString(DATA_COLUMN));
} else if (mime.equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) {
putPhoneNumber(contact, cursor);
} else if (mime.equals(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)) {
putEmail(contact, cursor);
} else if (mime.equals(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE)) {
putAddress(contact, cursor);
}else if (mime.equals(ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE)) {
contact.setU8sSIPAddress(cursor.getString(DATA_COLUMN));
}else if (mime.equals(ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)) {
wrapper.setImageBinaryString(getContactPhotoBase64(contactId));
}
}
cursor.close();
return wrapper;
}
private static void putPhoneNumber(ContactWrapper contact,Cursor data){
switch (data.getInt(DATATYPE_COLUMN)){
case ContactsContract.CommonDataKinds.Phone.TYPE_HOME:
contact.setU8sPhoneHome(data.getString(DATA_COLUMN));
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE:
contact.setU8sPhoneMobile(data.getString(DATA_COLUMN));
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK:
contact.setU8sPhoneBusiness(data.getString(DATA_COLUMN));
break;
}
}
试图制作一个总结数字的线程代码。它给出了下面的错误 如果名称 =='主要': freeze_support() ...
#!/usr/bin/env python3
from datetime import datetime
MAX_NUM = 10000
NUMPROCS = 1
# THREADING
from multiprocessing import Process, Queue
start_time = datetime.now()
def sum_range(start,stop,out_q):
i = start
counter = 0
while i < stop:
counter += i
i += 1
out_q.put(counter)
mysums = Queue()
mybounds = [1+i for i in range(0,MAX_NUM+1,int(MAX_NUM/NUMPROCS))]
myprocs = []
for i in range(NUMPROCS):
p = Process(target=sum_range, args=(mybounds[i],mybounds[i+1],mysums))
p.start()
myprocs.append(p)
mytotal = 0
for i in range(NUMPROCS):
mytotal += mysums.get()
for i in range(NUMPROCS):
myprocs[i].join()
print(mytotal)
end_time =datetime.now()
print('Time taken : {}'. format(end_time-start_time))