简体   繁体   English

Ruby相当于Python str [3:]

[英]Ruby equivalent of Python str[3:]

Is there a Ruby equivalent of Python's method for getting a substring that ends at the end of the string, like str[3:] ? 是否有Ruby等价的Python方法来获取一个以字符串结尾结束的子字符串,如str[3:] It's not convenient to have to put in the length of the string. 不得不放入字符串的长度是不方便的。

传递最后一个元素= -1的范围

str[3..-1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM