str = 'helloworld'.
截取:
str1 = str+0(5). "此时str1的值为'hello'
str2 = str+5(5). "此时str2的值为'world'
str3 = str(5). "此时str3的值为'hello'
替换:
str0 = 'hello'.
str4 = str.
str4+5(5) = str0."此时str4的值为'hellohello'
获取长度:
strlen( str )."strlen( str )的值为10
字符串操作技巧
本文介绍了如何进行字符串的基本操作,包括截取、替换及获取长度等。通过具体的代码示例,展示了如何实现这些操作。
str = 'helloworld'.
截取:
str1 = str+0(5). "此时str1的值为'hello'
str2 = str+5(5). "此时str2的值为'world'
str3 = str(5). "此时str3的值为'hello'
替换:
str0 = 'hello'.
str4 = str.
str4+5(5) = str0."此时str4的值为'hellohello'
获取长度:
strlen( str )."strlen( str )的值为10
1824
568
7354

被折叠的 条评论
为什么被折叠?