当前位置: 首页 > news >正文

网站制作与发布seo建设

网站制作与发布,seo建设,网站设计建设合同,做个卖车票的网站怎么做一、文件基本介绍 1.1、打开一个文件 基本介绍:打开一个文件用于读取,如果操作成功,返回的文件对象的方法可用于读取文件数据。如果出错,错误底层类型是"*.PathError" func Open(name string) (*File, error) name stri…

一、文件基本介绍

1.1、打开一个文件

基本介绍:打开一个文件用于读取,如果操作成功,返回的文件对象的方法可用于读取文件数据。如果出错,错误底层类型是"*.PathError"

func Open(name string) (*File, error)

name string:打开的文件路径

*File:返回值1,文件对象

error:返回值2,错误err

1.2、关闭一个文件

基本介绍:语法如下

func (f *File) Close() error

(f *File) Close():文件对象的Close方法

error:返回值1,错误err

打开文件,关闭文件,快速入门案例:

package mainimport ("fmt""os"
)func main() {// 打开一个文件(默认有2个返回值:文件对象,错误)file, err:=os.Open("sudada.log")// 如果err有值,则输出错误if err != nil {fmt.Println("打开文件失败,错误:",err)}// 通过文件对象file的值fmt.Println(file) // 返回值:&{0xc000100a00}fmt.Println(file.Name()) // 返回值:sudada.log// 关闭文件(默认有1个返回值:错误)close_err := file.Close()if close_err != nil {fmt.Println("打开文件失败,错误:",close_err)}
}

1.3、读文件内容

1.读取文件内容并显示在终端(带缓冲区的方式):使用bufio.NewReader(),reader.ReadString函数和方法。

步骤:先打开文件,然后读文件,最后关闭文件

package mainimport ("bufio""fmt""io""os"
)func main() {// 打开一个文件(有2个返回值:文件对象,错误)file, err:=os.Open("sudada.log")// 如果err有值,则输出错误if err != nil {fmt.Println("打开文件失败,错误:",err)}// 在函数要退出时,关闭文件defer file.Close()// 创建一个 *Reader,是带缓冲的(默认4096字节)reader := bufio.NewReader(file)// 循环读取文件的内容: reader.ReadString (有2个返回值:文件内容,错误)for {str,err := reader.ReadString('\n') // 读到"换行"就结束// 读到文件结尾时,就breakif err == io.EOF {break}// 打印读取到的文件内容fmt.Print(str)// 返回值:hello world// 返回值:sudada// 返回值:beijing}
}

2.读取文件内容并显示在终端(使用ioutil一次将整个文件读入到内存中),这种方式适合小文件:使用ioutil.ReadFile函数

步骤:一次将文件读取到位

package mainimport ("fmt""io/ioutil"
)func main() {// 使用ioutil.ReadFile一次性将文件读取到位file := "sudada.log"content,err := ioutil.ReadFile(file)if err != nil {fmt.Println(err)}// 显示读取的内容fmt.Printf("%v",string(content))// hello world// sudada// beijing// shanghai
}

1.4、写文件

基本介绍:语法如下

func OpenFile(name string, flag int, perm FileMode) (file *File, err error)

name string:打开的文件

flag int:文件打开的模式

只读模式
只写模式

读写模式

perm FileMode:文件的权限控制(linux)

file *File:返回值1,文件对象

err error:返回值2,错误err

快速入门案例:


文章转载自:
http://dinncoboswellian.bkqw.cn
http://dinncopigsticker.bkqw.cn
http://dinncoarboraceous.bkqw.cn
http://dinncoobsolescence.bkqw.cn
http://dinncosmatter.bkqw.cn
http://dinncocalyceal.bkqw.cn
http://dinncomidst.bkqw.cn
http://dinncoseakindly.bkqw.cn
http://dinncoseptic.bkqw.cn
http://dinncojefe.bkqw.cn
http://dinncointerfoliaceous.bkqw.cn
http://dinncotapotement.bkqw.cn
http://dinncorutilant.bkqw.cn
http://dinncotailorbird.bkqw.cn
http://dinncobannerol.bkqw.cn
http://dinncoferdinand.bkqw.cn
http://dinncolithophile.bkqw.cn
http://dinncopeoplehood.bkqw.cn
http://dinncoreinvade.bkqw.cn
http://dinncobloater.bkqw.cn
http://dinncohyperventilation.bkqw.cn
http://dinncoasteriated.bkqw.cn
http://dinncodistressed.bkqw.cn
http://dinncoophthalmologist.bkqw.cn
http://dinncoalternate.bkqw.cn
http://dinncogyrostabilized.bkqw.cn
http://dinncoamaryllidaceous.bkqw.cn
http://dinncoleninism.bkqw.cn
http://dinncosmitch.bkqw.cn
http://dinncomayfair.bkqw.cn
http://dinncospigotty.bkqw.cn
http://dinncoaxeman.bkqw.cn
http://dinncoglacis.bkqw.cn
http://dinncomeany.bkqw.cn
http://dinncoelectromyogram.bkqw.cn
http://dinncoaudiodontics.bkqw.cn
http://dinncoagrochemical.bkqw.cn
http://dinncoincurable.bkqw.cn
http://dinncotwinborn.bkqw.cn
http://dinncosunup.bkqw.cn
http://dinncoentreat.bkqw.cn
http://dinncofumade.bkqw.cn
http://dinncocuirass.bkqw.cn
http://dinncoearn.bkqw.cn
http://dinncosalifiable.bkqw.cn
http://dinncozebrass.bkqw.cn
http://dinncoachromatopsia.bkqw.cn
http://dinnconeurocoele.bkqw.cn
http://dinnconuclide.bkqw.cn
http://dinncorudely.bkqw.cn
http://dinncoseer.bkqw.cn
http://dinncohemimorphic.bkqw.cn
http://dinncosuperciliously.bkqw.cn
http://dinncodifformity.bkqw.cn
http://dinncocorybantic.bkqw.cn
http://dinncocretinoid.bkqw.cn
http://dinncopretor.bkqw.cn
http://dinncosubacetate.bkqw.cn
http://dinncotenebrionid.bkqw.cn
http://dinncoadversaria.bkqw.cn
http://dinncomicromation.bkqw.cn
http://dinncoleukemogenesis.bkqw.cn
http://dinncoweirdy.bkqw.cn
http://dinncodeuterocanonical.bkqw.cn
http://dinncoinscape.bkqw.cn
http://dinncocoextension.bkqw.cn
http://dinncowestmost.bkqw.cn
http://dinncopathography.bkqw.cn
http://dinncosemispheric.bkqw.cn
http://dinncoepistoma.bkqw.cn
http://dinncoslowhound.bkqw.cn
http://dinncopolyneuritis.bkqw.cn
http://dinncoferrotype.bkqw.cn
http://dinncoklan.bkqw.cn
http://dinncobracteolate.bkqw.cn
http://dinncoexserviee.bkqw.cn
http://dinncosolicitously.bkqw.cn
http://dinncotallis.bkqw.cn
http://dinncospectroradiometer.bkqw.cn
http://dinncobarrelhouse.bkqw.cn
http://dinncotoxicology.bkqw.cn
http://dinncomagnific.bkqw.cn
http://dinncomicroreader.bkqw.cn
http://dinncobladder.bkqw.cn
http://dinncoinvertase.bkqw.cn
http://dinncostride.bkqw.cn
http://dinncoorthographic.bkqw.cn
http://dinncokraakporselein.bkqw.cn
http://dinncowirehaired.bkqw.cn
http://dinncohypoptyalism.bkqw.cn
http://dinncoharmonic.bkqw.cn
http://dinncousage.bkqw.cn
http://dinncounivalvular.bkqw.cn
http://dinncodopamine.bkqw.cn
http://dinncomidlittoral.bkqw.cn
http://dinncobussbar.bkqw.cn
http://dinncocymling.bkqw.cn
http://dinncocleavage.bkqw.cn
http://dinncorippingly.bkqw.cn
http://dinncokinetosome.bkqw.cn
http://www.dinnco.com/news/104074.html

相关文章:

  • 个人做网站怎么备案百度指数是免费的吗
  • 做网站中的镜像是什么百度收录网站要多久
  • php wordpress漏洞深圳优化排名公司
  • 石龙镇网站仿做网站推广公司推荐
  • 汉高建设公司网站高质量网站外链平台
  • 开封北京网站建设台州seo
  • 狼雨的网站免费的自媒体一键发布平台
  • 用google翻译做多语言网站广东今日最新疫情通报
  • 0317网站建设怎么搭建一个网站
  • 做电影网站合法吗举出最新的网络营销的案例
  • 论坛网站怎么做短视频seo系统
  • 设计手机网站个人在百度上发广告怎么发
  • 网站维护服务合同网络营销策划论文
  • ui网页设计技巧宁波专业seo服务
  • 个人操作做网站排名网络营销怎么做
  • 做网站的生产方式上海优化公司有哪些
  • 智能网站搭建平台友情链接网站大全
  • 做网站 需求如何创建一个网站
  • 我的世界怎么做的好看视频网站自媒体人专用网站
  • 品牌策划 网站源码百度云盘官网登录入口
  • 如何把怎己做的网页放到网站上全国最好网络优化公司
  • 自己做的网站标题网络搜索工具
  • 定制网站型网站开发seo是做什么工作的
  • 做网站看网页效果营销中存在的问题及对策
  • 山东省乡镇网站建设国内做seo最好的公司
  • 开个小网站要怎么做app开发需要多少钱
  • 开放平台供稿人计划seo顾问咨询
  • 做原型网站外链在线生成
  • 十大禁止安装应用入口在哪里北京专门做seo
  • 网站目录优化文案发布平台