的last()
是在朱一个内置函数,其用于返回由指定的字符串,其中,n为将参数传递的最后n字符的字符串。
Syntax:
last(s::AbstractString, n::Integer)
Parameters:
- s::AbstractString: Specified string.
- n::Integer: Specified integer value.
Returns: It returns a string consisting of the last n characters of the specified string, where n will be passed as parameter.
示例 1:
# Julia program to illustrate
# the use of String last() method
# Getting a string consisting of the last
# n characters of the specified string
println(last("GeeksforGeeks", 0))
println(last("GeeksforGeeks", 5))
println(last("GeeksforGeeks", 8))
println(last("GeeksforGeeks", 10))
输出:
示例 2:
# Julia program to illustrate
# the use of String last() method
# Getting a string consisting of the last
# n characters of the specified string
println(last("1 + 2+3 + 4", 0))
println(last("2-4-6-8", 4))
println(last("1 * 3*5 * 7", 6))
输出: