这个repeat()
是 julia 中的一个内置函数,用于返回一个字符串,该字符串是指定字符串重复指定次数的字符串。
用法:
repeat(String::AbstractString, r::Integer)
参数:
- String:指定的字符串或字符
- r::整数:指定次数
返回值:它返回一个字符串,它是指定字符串重复指定次数的字符串。
范例1:
# Julia program to illustrate
# the use of String repeat() method
# Create a repetition of string "gfg"
# with 3 times of repetition.
println(repeat("gfg", 3))
# Create a repetition of character "a"
# with 4 times of repetition.
println(repeat("a", 4))
# Create a repetition of string "Geeks"
# with 2 times of repetition.
println(repeat("Geeks", 2))
# Create a repetition of string "@#"
# with 3 times of repetition.
println(repeat("@#", 3))
输出:
gfggfggfg aaaa GeeksGeeks @#@#@#
范例2:
# Julia program to illustrate
# the use of String repeat() method
# Create a repetition of string "123"
# with 3 times of repetition.
println(repeat("123", 3))
# Create a repetition of string "22"
# with 4 times of repetition.
println(repeat("22", 4))
# Create a repetition of string "03210"
# with 2 times of repetition
println(repeat("03210", 2))
输出:
123123123 22222222 0321003210
相关用法
- Julia repeat()用法及代码示例
- Julia sizeof()用法及代码示例
- Julia findlast()用法及代码示例
- Julia length()用法及代码示例
- Julia SubString()用法及代码示例
- Julia findfirst()用法及代码示例
- Julia first()用法及代码示例
- Julia last()用法及代码示例
- Julia Array findall()用法及代码示例
- Julia Array findprev()用法及代码示例
- Julia Array findnext()用法及代码示例
- Julia Array findfirst()用法及代码示例
- Julia Array findlast()用法及代码示例
- Julia ndims()用法及代码示例
- Julia length()用法及代码示例
- Julia size()用法及代码示例
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Get repetition of a string in Julia – repeat() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。