Tag archives: File

RSS feed of File

Python read and write files

Python read and write file

1.Python read and write file

fr=open("readfile.txt","r")  
fw=open("writefile.txt","w")

print fr.readline()  
print fr.tell()

print fr.readlines()  
fw.write("===write line===")  
fw.close()

fr.seek(0,0) #The first parameter represents the number of bytes, after which a parameter represents the relative ...

Continue reading

linux c library function to read binary file code

linux c library function to read binary file code

struct person
{
    int id;
    char name[20];
    int age;
    int sex;
    char tel[20];
};


int main(int arg, char *args[])
{
    FILE *p = fopen(args[1], "w");
    if (p == NULL)
    {
        printf("error is %s\n", strerror(errno));
    } else
    {
        printf("success\n");
        struct person man;
        memset(&man, 0 ...

Continue reading