我想创建一个Array
Strings
存储“名称”;并且这些名称应该用于创建由数组中的字符串命名的新ArrayLists。
这种方式不起作用。有没有办法管理这个或者你可以解释为什么不可能?
public String combiTop [] = {"1er","2er","3er","4er","5er","6er"};
topRowValue = new ArrayList<>();
for (int i = 0; i < combiTop.length; i++) {
ArrayList<Integer> combiTop[i] = new ArrayList<>();
for (int j = 0; j < 6; j++) {
combiTop[i].add(-1);
}
topRowValue.add(combiTop[i]);
}
答案 0 :(得分:0)
在Java中,同一函数中的变量是固定类型的,因此您不能将ArrayList值分配给String数组或其内部的值。因此:
def download_attachments_in_mailbox(self):
# Note: This function definition needs to be placed
# before the previous block of code that calls it.
rv, data = self._M.search(None, "ALL")
if rv != 'OK':
print "No messages found!"
return
for num in data[0].split():
rv, data = self._M.fetch(num, '(RFC822)')
if rv != 'OK':
print "ERROR getting message", num
return
mail = email.message_from_string(data[0][1])
for part in mail.walk():
if part.get_content_maintype() == 'multipart':
# print part.as_string()
continue
if part.get('Content-Disposition') is None:
# print part.as_string()
continue
fileName = part.get_filename()
if bool(fileName):
filePath = os.path.join(detach_dir, fileName)
if not os.path.isfile(filePath):
print fileName
fp = open(filePath, 'wb')
fp.write(part.get_payload(decode=True))
fp.close()