技术栈

Scala中字符串

爱吃香菜---www2024-11-28 14:28
复制代码
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)
  }
  }
}
上一篇:正则表达式
下一篇:Spring Boot的JdbcTemplate实现“不存在即插入,存在即更新”
相关推荐
John Song
1 天前
Python创建虚拟环境的方式对比与区别?
开发语言·python
搞程序的心海
1 天前
Python面试题(一):5个最常见的Python基础问题
开发语言·python
parafeeee
1 天前
程序人生-Hello’s P2P
数据库·后端·asp.net
MediaTea
1 天前
Python:collections.Counter 常用函数及应用
开发语言·python
bug攻城狮
1 天前
Spring Boot应用内存占用分析与优化
java·jvm·spring boot·后端
LawrenceLan
1 天前
37.Flutter 零基础入门(三十七):SnackBar 与提示信息 —— 页面反馈与用户交互必学
开发语言·前端·flutter·dart
李昊哲小课
1 天前
Python json模块完整教程
开发语言·python·json
易醒是好梦
1 天前
Python flask demo
开发语言·python·flask
热门推荐
01GitHub 镜像站点02OpenClaw 使用和管理 MCP 完全指南03本地部署 OpenClaw + DeepSeek-R1 完全指南04Qwen3.5 开源全解析:从 0.8B 到 397B,代际升级 + 全场景选型指南05OpenClaw 飞书机器人不回复消息?3 小时踩坑总结06OpenClaw macOS 完整安装与本地模型配置教程(实战版)07得物前端部门,没了08OpenClaw 连接飞书完整指南:插件安装、配置与踩坑记录09Window 10部署openclaw报错node.exe : npm error code 12810OpenClaw 接入 QQ Bot 完整实践指南