Tag: 文件

Python如何使用临时文件

Jackey Python 1,610 次浏览 ,
# 如何使用临时文件 from tempfile import TemporaryFile, NamedTemporaryFile # 系统中无法找到这个临时文件,只能本进程访问 f = TemporaryFile() f.write(b'abcdef' * 100000) f.seek(0) print(f.read(100)) # 系统中...

Python如何访问文件的状态

Jackey Python 1,637 次浏览 ,
# 如何访问文件的状态 import os print(os.stat('p.txt')) print(os.lstat('p.txt')) f = open('p.txt') print(os.fstat(f.fileno())) s = os.stat('p.txt') print(s) # 文件类型,标志位构成 print(s.st_mode) impor...

Python如何读写文本文件

Jackey Python 1,596 次浏览 ,
# 如何读写文本文件 s = '你好' print(s.encode('utf8')) print(s.encode('gbk')) # b 代表byte print(b'abc') # wt t 是默认方式 f = open('py3.txt', 'wt', encoding='utf8') f.write('你好,ijackey.com') f.cl...

Golang 文件操作

Jackey Golang 2,756 次浏览 ,
读取文件(带缓冲区) readFile.go package main import ( "bufio" "fmt" "io" "os" ) func main() { // 打开文件 file, err := os.Open("/Users/jackey/Downloads/3.txt") if err != nil { fmt.P...

PHP文件核心编程

Jackey PHP 2,981 次浏览 ,
想一想:什么是文件? Linux文件 定义:存储在某种设备中的一段数据流 在Linux中,几乎一切都是文件 文件类型:普通文件、链接文件、目录文件、设备文件 设备文件:/dev/tty, /dev/null, /dev/zero 每个文件对应一...
Go