readline_Swift readLine(),Swift print()

readline

In this tutorial, we’ll be discussing how to read the standard input in Swift from the user and the different ways to print the output onto the screen. Swift print() is the standard function to display an output onto the screen.

在本教程中,我们将讨论如何从用户中读取Swift中的标准输入以及将输出打印到屏幕上的不同方法。 Swift print()是在屏幕上显示输出的标准函数。

Let’s get started by creating a new command line application project in XCode.

让我们开始使用XCode创建一个新的命令行应用程序项目。

快速输入 (Swift Input)

In Swift, the standard input is not possible in Playgrounds. Neither in iOS Application for obvious reasons. Command Line Application is the possible way to read inputs from the user.

在Swift中,标准输入在Playgrounds中是不可能的。 出于明显的原因,iOS应用程序中都没有。 命令行应用程序是从用户读取输入的可能方法。

readLine() is used to read the input from the user. It has two forms:

readLine()用于从用户读取输入。 它有两种形式:

  • readLine() : The default way.

    readLine() :默认方式。
  • readLine(strippingNewLine: Bool) : This is default set to true. Swift always assumes that the newline is not a part of the input

    readLine(strippingNewLine: Bool) :默认设置为true。 Swift始终假定换行符不是输入的一部分

readLine() function always r

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值