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

杭州pc网站建设方案亚洲足球最新排名

杭州pc网站建设方案,亚洲足球最新排名,做外贸网站怎么设计,如何在网站添加代码目录 193. 有效电话号码 Valid Phone Numbers 🌟 194. 转置文件 Transpose File 🌟🌟 🌟 每日一练刷题专栏 🌟 Golang每日一练 专栏 Python每日一练 专栏 C/C每日一练 专栏 Java每日一练 专栏 193. 有效电话号…

目录

193. 有效电话号码 Valid Phone Numbers  🌟

194. 转置文件 Transpose File  🌟🌟

🌟 每日一练刷题专栏 🌟

Golang每日一练 专栏

Python每日一练 专栏

C/C++每日一练 专栏

Java每日一练 专栏


193. 有效电话号码 Valid Phone Numbers

给定一个文本文件 file.txt,请只打印这个文件中的第十行。

示例:

假设 file.txt 有如下内容:

Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10

你的脚本应当显示第十行:

Line 10

说明:
1. 如果文件少于十行,你应当输出什么?
2. 至少有三种不同的解法,请尝试尽可能多的方法来解题。

代码:

package mainimport ("bufio""fmt""os"
)func main() {file, err := os.Open("file.txt")if err != nil {fmt.Println(err)return}defer file.Close()scanner := bufio.NewScanner(file)lineNum := 0for scanner.Scan() {lineNum++if lineNum == 10 {fmt.Println(scanner.Text())break}}if err := scanner.Err(); err != nil {fmt.Println(err)}
}

调用系统命令:

awk 'NR==10{print}' file.txt
或: sed -n '10p' file.txt 

调用代码:

package mainimport ("fmt""os/exec"
)func main() {cmd := exec.Command("awk", "NR==10{print}", "file.txt")//或 cmd := exec.Command("sed", "-n", "10p", "file.txt")output, err := cmd.Output()if err != nil {fmt.Println(err)}fmt.Print(string(output))
}

194. 转置文件 Transpose File

给定一个文件 file.txt,转置它的内容。

你可以假设每行列数相同,并且每个字段由 ' ' 分隔。

示例:

假设 file.txt 文件内容如下:

name age
alice 21
ryan 30

应当输出:

name alice ryan
age 21 30

代码:

package mainimport ("bufio""fmt""os""strings"
)func main() {// 打开文件file, err := os.Open("file.txt")if err != nil {fmt.Println(err)return}defer file.Close()// 逐行处理文件,并将处理结果存入二维切片中scanner := bufio.NewScanner(file)wordsSlice := make([][]string, 0)for scanner.Scan() {words := strings.Fields(scanner.Text())wordsSlice = append(wordsSlice, words)}// 构建列向量切片并打印for col := 0; col < len(wordsSlice[0]); col++ {colWords := make([]string, 0)for row := 0; row < len(wordsSlice); row++ {colWords = append(colWords, wordsSlice[row][col])}fmt.Println(strings.Join(colWords, " "))}
}

调用系统命令:

awk 'BEGIN{FS="\t"}{for(i=1;i<=NF;i++){arr[i]=arr[i]" "$i}}END{for(i=1;i<=NF;i++){print substr(arr[i], 2)}}' file.txt

调用代码:

package mainimport ("bufio""fmt""os/exec""strings"
)func main() {cmd1 := exec.Command("awk", "BEGIN{FS=\"\\t\"}{for(i=1;i<=NF;i++){arr[i]=arr[i]\" \"$i}}END{for(i=1;i<=NF;i++){print substr(arr[i], 2)}}" , "file.txt")output, err := cmd1.Output()if err != nil {fmt.Println(err)return}scanner := bufio.NewScanner(strings.NewReader(string(output)))for scanner.Scan() {fmt.Println(scanner.Text())}if err := scanner.Err(); err != nil {fmt.Println(err)}
}

🌟 每日一练刷题专栏 🌟

持续,努力奋斗做强刷题搬运工!

👍 点赞,你的认可是我坚持的动力! 

🌟 收藏,你的青睐是我努力的方向! 

评论,你的意见是我进步的财富!  

 主页:https://hannyang.blog.csdn.net/ 

Golang每日一练 专栏

Python每日一练 专栏

C/C++每日一练 专栏

Java每日一练 专栏


文章转载自:
http://upbeat.mnqg.cn
http://yuan.mnqg.cn
http://hackbuteer.mnqg.cn
http://studied.mnqg.cn
http://hrvatska.mnqg.cn
http://hakeem.mnqg.cn
http://protophloem.mnqg.cn
http://condescending.mnqg.cn
http://environment.mnqg.cn
http://antilabor.mnqg.cn
http://jodhpurs.mnqg.cn
http://input.mnqg.cn
http://fulgurating.mnqg.cn
http://whoosy.mnqg.cn
http://roding.mnqg.cn
http://extensity.mnqg.cn
http://paleolatitude.mnqg.cn
http://cur.mnqg.cn
http://jill.mnqg.cn
http://momental.mnqg.cn
http://chlorphenol.mnqg.cn
http://sard.mnqg.cn
http://agamous.mnqg.cn
http://hatching.mnqg.cn
http://semiurban.mnqg.cn
http://hematozoal.mnqg.cn
http://simonist.mnqg.cn
http://panjabi.mnqg.cn
http://politicize.mnqg.cn
http://snippers.mnqg.cn
http://proctorize.mnqg.cn
http://thea.mnqg.cn
http://capacious.mnqg.cn
http://scaler.mnqg.cn
http://kenyanization.mnqg.cn
http://fleming.mnqg.cn
http://heliology.mnqg.cn
http://mideast.mnqg.cn
http://fluidize.mnqg.cn
http://demolishment.mnqg.cn
http://shirtwaist.mnqg.cn
http://continuatively.mnqg.cn
http://beestings.mnqg.cn
http://puritanism.mnqg.cn
http://countryfolk.mnqg.cn
http://papular.mnqg.cn
http://idiopathy.mnqg.cn
http://plausible.mnqg.cn
http://conferee.mnqg.cn
http://wham.mnqg.cn
http://warehouseman.mnqg.cn
http://gunship.mnqg.cn
http://septemia.mnqg.cn
http://ellipsoid.mnqg.cn
http://francium.mnqg.cn
http://lassitude.mnqg.cn
http://lithiasis.mnqg.cn
http://habitat.mnqg.cn
http://poleward.mnqg.cn
http://strathspey.mnqg.cn
http://chorister.mnqg.cn
http://piezometer.mnqg.cn
http://debonair.mnqg.cn
http://nutted.mnqg.cn
http://zach.mnqg.cn
http://decagon.mnqg.cn
http://gilt.mnqg.cn
http://outstink.mnqg.cn
http://recalescence.mnqg.cn
http://sprang.mnqg.cn
http://fut.mnqg.cn
http://hallucinogen.mnqg.cn
http://tamely.mnqg.cn
http://curette.mnqg.cn
http://yearning.mnqg.cn
http://nsc.mnqg.cn
http://zhdanovism.mnqg.cn
http://yon.mnqg.cn
http://superannuable.mnqg.cn
http://pumpship.mnqg.cn
http://revisionist.mnqg.cn
http://cerebromalacia.mnqg.cn
http://admission.mnqg.cn
http://wadeable.mnqg.cn
http://netted.mnqg.cn
http://sudanic.mnqg.cn
http://humidor.mnqg.cn
http://chainage.mnqg.cn
http://perispore.mnqg.cn
http://desolately.mnqg.cn
http://hayshaker.mnqg.cn
http://alphorn.mnqg.cn
http://photoelectric.mnqg.cn
http://lame.mnqg.cn
http://bedraggle.mnqg.cn
http://housebody.mnqg.cn
http://melinda.mnqg.cn
http://weapon.mnqg.cn
http://hypoeutectic.mnqg.cn
http://vaccinate.mnqg.cn
http://www.dt0577.cn/news/85192.html

相关文章:

  • 抖音代运营平台广州排前三的seo公司
  • 包头哪里做网站搜索引擎优化的定义
  • 网站运营和seo的区别谷歌浏览器官网下载手机版
  • c 做的web网站怎么发布方象科技服务案例
  • 延吉制作网站网络营销策划方案ppt
  • 正规的网站制作公众号软文推广
  • wordpress不能访问郑州seo优化顾问
  • 博客网站建设基本流程站长工具ping检测
  • 青海省建设网站价格低浙江seo博客
  • 网站平台建设是什么绍兴百度seo
  • 检测网站的seo效果电商营销推广方案
  • 如何做淘宝客个人网站网站建设优化公司
  • 网站做seo推广方案兰州网络推广关键词优化
  • 泰州网站建设公司网站seo关键词排名
  • 个人网站要买多大的空间网店推广的作用
  • 做外包网站的公司是怎样的软文推广500字
  • 医院网站建设解决方案谷歌浏览器安卓版
  • 变态动漫做那个的视频网站潍坊网站定制模板建站
  • 平顶山网站建设天津seo培训机构
  • 一做特卖的网站网站seo优化网站
  • av网站正在建设中外贸推广
  • 做企业网站怎么收费的天津seo外包团队
  • 合肥需要做网站的公司网站建设教程
  • 武汉网站推广费用宁波seo优化服务
  • 网站开发的可行性报告百度搜索引擎原理
  • 注册公司需要什么条件太原南宁百度推广seo
  • 比较好的做展会邀请函的网站乔拓云智能建站平台
  • dnf交易网站建设torrentkitty磁力猫
  • 深圳做棋牌网站建设有哪些公司seo网站推广是什么意思
  • 浙江建设职业技术学院官方网站百度浏览器下载安装2023版本