在 Julia 中将字符串转换为大写 – uppercase() 和 uppercasefirst() 方法
uppercase()
是 julia 中的内置函数,用于返回所有字符都转换为大写的字符串。
Syntax: uppercase(s::AbstractString)
Parameters:
- s::AbstractString: Specified string.
Returns: It returns a string with all characters converted to uppercase.
例子:
# Julia program to illustrate
# the use of uppercase() method
# Getting a string with all
# characters converted to uppercase
println(uppercase("gfg"))
println(uppercase("geeks"))
println(uppercase("geeksforgeeks"))
输出:
GFG
GEEKS
GEEKSFORGEEKS
大写优先
uppercasefirst()
是 julia 中的内置函数,用于返回第一个字符转换为大写的字符串。
Syntax: uppercasefirst(s::AbstractString)
Parameters:
- s::AbstractString: Specified string.
Returns: It returns a string with first character converted to uppercase.
例子:
# Julia program to illustrate
# the use of uppercasefirst() method
# Getting a string with first
# character converted to uppercase
println(uppercasefirst("gfg"))
println(uppercasefirst("geeks"))
println(uppercasefirst("geeksforgeeks"))
输出: