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)
  }
  }
}
相关推荐
踩着两条虫6 小时前
「AI + 低代码」的可视化设计器
开发语言·前端·低代码·设计模式·架构
JoneBB7 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
Spider Cat 蜘蛛猫7 小时前
Springboot SSO系统设计文档
java·spring boot·后端
即使再小的船也能远航7 小时前
【Python】安装
开发语言·python
Irissgwe7 小时前
类与对象(三)
开发语言·c++·类和对象·友元
雪度娃娃8 小时前
转向现代C++——优先选用nullptr而不是0和NULL
开发语言·c++
zyk_computer8 小时前
AI 时代,或许 Rust 比 Python 更合适
人工智能·后端·python·ai·rust·ai编程·vibe coding
萌新小码农‍8 小时前
python装饰器
开发语言·前端·python
KK溜了溜了8 小时前
Python从入门到精通
服务器·开发语言·python
雨辰AI8 小时前
SpringBoot3 项目国产化改造完整流程|从 MySQL 到人大金仓落地
java·数据库·后端·mysql·政务