📜  在 Julia 中获取字符串的重复 – repeat() 方法

📅  最后修改于: 2022-05-13 01:55:36.755000             🧑  作者: Mango

在 Julia 中获取字符串的重复 – repeat() 方法

repeat()是 julia 中的一个内置函数,用于返回一个字符串,该字符串是指定字符串在指定次数内的重复。

示例 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