2016-04-20 63 views
-1
#!/usr.byn/python3 

import struct 

class Fat: 
def __init__(self, fat): 
self._fat 

    def entryValue(self, cluster): 
    value = struct.unpackf=t('I', fat[cluster*4:cluster*4+4])[0] 
    return value 

    def isAllocated(self, cluster): 
    return self.entryValue(cluster)!=0 

    def nextCluster(self, cluster): 
     if (self.entryValue(cluster)==0 or 
     self.entryValue(cluster)==0x0fffffff): 
     return None 
      else: 
     return self.entryValue(cluster) 

    def clusterChain(self,cluster): 
    list1 =[] 
    while isAllocated: 
    for item in isAllocated: 
    continue 
    list1.append 
    value = 0 




''' make empty list, if cluster is allocated append it to list 
if not allocated start at new cluster, return list 
make do while loop''' 

def main(): 
with open('/home/louis/Downloads/fat-only.dd', 'rb') as f: 
fat=f.read() 
fat1=Fat(fat) 

由于我还在学习python,我仍然有一些代码写入问题,任何帮助将不胜感激。正如在我的第三种方法的评论中提到的那样,我需要检查是否已分配群集,如果它已被添加到列表中,并且如果不是,则会进入下一个群集。对于第三种方法如何继续或改变什么,我感到非常困惑,我知道至少我的前两项在我以前寻求的帮助中很好。方法调用问题

+4

你应该更改标题不要在这里得到downvoted,也是你的代码是不缩进。 – Dodekeract

+0

请记住,python代码块是通过它的标识级别来定义的,与其他标记用于定义所述代码块的其他标记不同,其他标记用于定义所述代码段 – Copperfield

+0

当我从电子邮件中复制并粘贴该代码时,邮件,正在使用不同的笔记本电脑进行工作,所以通过电子邮件发送给自己并将其复制到此处,缩进级别全部搞砸了。以为我做了缩进,虽然张贴,感谢指出。 –

回答

0

只是一些意见:

class Fat: 
    def __init__(self, fat): 
    self._fat # <------------------- this should be given a value 

def clusterChain(self,cluster): 
    list1 =[] 
    while isAllocated: # <---------- this doesn't actually call the function 
     for item in isAllocated: 
      continue 
     list1.append # <------------ this does nothing 
    value = 0 # <------------------- this looks undefined 
+0

好的感谢您的反馈意见,您指出我会试着说我想做的事情。对于第一个我不知道要添加什么价值。对于第三种方法中的第二种,我试图编写for while循环。当list1.append中的第三个发现一个被分配的集群应该被添加到列表中时,第四个仍然是未定义的。我只是在如何正确修复第三种方法方面画了一个巨大的空白。 –