我正在编写一个列出目录名称的程序。这不是一个非常复杂的代码,但是在启动程序后,我得到了奇怪的错误
df.isnull().sum() * 100 / len(df)
我得到的输出是
#include <dirent.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main() {
struct dirent * dir;
struct stat buf;
DIR *d;
if(d = opendir("/..."))
{
while(dir = readdir(d))
{
if(S_ISDIR(buf.st_mode))
puts(dir->d_name);
closedir(d);
}
}
else
perror("read");
return 0;
}
我做错了什么?
答案 0 :(得分:5)
正在从目录流中读取时关闭目录流。更改:
I made a mistake in the code i returned a null value from statiDB class, i didnt intialize List Object, so i modified the code as shown below
**This complete code below was missing in above question**
```
in dao class
```
public class DoctorDao {
public boolean saveUser(Doctor doc) {
boolean storedStatus = StaticDB.getDoctorList().add(doc);
return storedStatus;
}
}
```
In DB class
```
class StaticDB{
static List<Doctor> docList=null;
public static List<Doctor> getDoctorList(){
Doctor doc1=new Doctor(111,"Shalu","ss@gmail.com");
Doctor doc2=new Doctor(112,"luke","luke@gmail.com");
docList=new ArrayList<Doctor>(); //This was missing
docList.add(doc1);
docList.add(doc2);
return docList;
收件人:
while(dir = readdir(d))
{
if(S_ISDIR(buf.st_mode))
puts(dir->d_name);
closedir(d);
}
这样一来,您就必须先完成操作才能关闭它。