📜  在 Julia 中获取字符串的长度 – length() 方法

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

在 Julia 中获取字符串的长度 – length() 方法

length()是 julia 中的内置函数,用于返回指定字符串的长度以及所需的开始和结束位置。

示例 1:

# Julia program to illustrate 
# the use of String length() method
  
# Finding the length of the string
# "Geeks"
println(length("Geeks"))
  
# Finding the length of the string
# "Geeks" from 2nd to 4th position
println(length("Geeks", 2, 4))
  
# Finding the length of the string
# "Geeks" from 2nd to 5th position
println(length("Geeks", 2, 5))
  
# Finding the length of the string
# "GeeksforGeeks" 
println(length("GeeksforGeeks"))
  
# Finding the length of the string
# "GeeksforGeeks" from 2nd to 2nd position
println(length("GeeksforGeeks", 2, 2))
  
# Finding the length of the string
# "GeeksforGeeks" from 4th to 10th position
println(length("GeeksforGeeks", 4, 10))

输出:
示例 2:

# Julia program to illustrate 
# the use of String length() method
   
# Finding the length of the string
# "12345"
println(length("12345"))
   
# Finding the length of the string
# "12345" from 2nd to 4th position
println(length("12345", 2, 4))
   
# Finding the length of the string
# "2468" from 1st to 3rd position
println(length("2468", 2, 3))

输出: