golang io ioutil包簡單使用

2022-08-30 19:27:06 字數 522 閱讀 3588

package main

import (

"fmt"

"io/ioutil"

"strings"

)func main()

//讀取整個檔案資料

data, _ := ioutil.readfile("./1.rtf")

fmt.println(string(data))

//建立檔案,存在清空檔案

ioutil.writefile("./1.txt", byte("111"), 0655)

//建立指定字首的臨時資料夾,返回資料夾名稱

dir, _ := ioutil.tempdir("./", "test")

fmt.println(dir)

//建立test為字首的臨時檔案,返回os.file指標

f, _ := ioutil.tempfile("./", "test")

f.write(byte("222"))

f.close()

}

揹包 01揹包,完全揹包,多重揹包

哈哈 01揹包 f i v max 完全揹包 f i v max 多重揹包 f i v max include include include include include define maxn 1000 using namespace std int n,cap int w maxn 重量 花...

mac包,ip包,tcp包 格式說明

圖 三 乙太網路的 mac 訊框 在這個 mac 當中,最重要的就是那個 6 bytes 的目的與來源位址了!事實上,在所有的乙太網路卡當中都有乙個獨一無二的網路卡卡號,那就是上頭的 目的與來源位址 這個位址是硬體位址 hardware address 共有 6 bytes 分別由 00 00 00...

http協議包 請求包和應答包

1 http請求包 http請求包 get post等請求方法 由三個部分構成,分別是 方法 uri 協議 版本,請求頭,請求正文。下面是乙個http請求包 get 的例子 socket socket new socket 127.0.0.1 8080 outputstream os socket....