Scala中字符串

复制代码
package test_33

import scala.io.Source
//成绩分析
object test {
  def main(args: Array[String]): Unit = {
    //1.读入成绩,按行去读取
   val it= Source.fromFile("score.txt").getLines().drop(1)
    while (it.hasNext){
      val content=it.next()
    //使用中文的逗号去拆分字符串
      var arr=content.split(",")
      val name=arr(0)
      val yuwen=arr(1).toInt
      val shuxue=arr(2).toInt
      val yingyu=arr(3).toInt
      val total=yuwen+shuxue+yingyu
      val avg=total / 3
      println("当前行是",name,yingyu,total)
  }
  }
}
相关推荐
FuckPatience1 小时前
Visual Studio C# 项目中文件后缀简介
开发语言·c#
码事漫谈7 小时前
当AI开始“思考”:我们是否真的准备好了?
前端·后端
014-code8 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024068 小时前
组合模式(Composite Pattern)
开发语言
游乐码9 小时前
c#泛型约束
开发语言·c#
Dontla9 小时前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen9 小时前
python rest请求、requests
开发语言·python
铁东博客9 小时前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang
baidu_huihui9 小时前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳9 小时前
Python从入门到精通day63
开发语言·python