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)
  }
  }
}
相关推荐
神经毒素2 分钟前
WEB安全--Java安全--LazyMap_CC1利用链
java·开发语言·网络·安全·web安全
酷炫码神28 分钟前
C#语法基础
开发语言·c#
ddd...e_bug28 分钟前
GMT之Bash语言使用
开发语言·bash
码农秋31 分钟前
填坑记: 古董项目Apache POI 依赖异常排除
开发语言·tomcat·jsp·poi·依赖冲突
qq_6536444631 分钟前
如何查看打开的 git bash 窗口是否是管理员权限打开
开发语言·windows·git·bash
sadoshi32 分钟前
phpstudy的Apache添加AddType application/x-httpd-php .php .php5配置无效的处理方式
开发语言·php·apache
阑梦清川1 小时前
关于Go语言的开发环境的搭建
开发语言·后端·golang
lyrhhhhhhhh1 小时前
Spring 模拟转账开发实战
java·后端·spring
言之。1 小时前
Makefile 在 Go 项目中的实践
开发语言·elasticsearch·golang
Nobkins1 小时前
2023CCPC河南省赛暨河南邀请赛个人补题ABEFGHK
开发语言·数据结构·c++·算法·图论