An integer is required? open()

前端 未结 5 1568
遇见更好的自我
遇见更好的自我 2020-11-28 10:43

I have a very simple python script that should scan a text file, which contains lines formatted as id=\'value\' and put them into a dict.

5条回答
  •  佛祖请我去吃肉
    2020-11-28 11:07

    From http://www.tutorialspoint.com/python/os_open.htm you could also keep your import and use

    file = os.open( "foo.txt", mode )

    and the mode could be :

    os.O_RDONLY: open for reading only
    os.O_WRONLY: open for writing only
    os.O_RDWR : open for reading and writing
    os.O_NONBLOCK: do not block on open
    os.O_APPEND: append on each write
    os.O_CREAT: create file if it does not exist
    os.O_TRUNC: truncate size to 0
    os.O_EXCL: error if create and file exists
    os.O_SHLOCK: atomically obtain a shared lock
    os.O_EXLOCK: atomically obtain an exclusive lock
    os.O_DIRECT: eliminate or reduce cache effects
    os.O_FSYNC : synchronous writes
    os.O_NOFOLLOW: do not follow symlinks
    

提交回复
热议问题