我如何在 javascript 中复制 python rfind 和字符串乘法?
How would I replicate python rfind and string multiplication in javascript?
我有这个 python 代码,我想在 Javascript 中复制它,但我不知道如何执行 Python 的 rfind 或 find 方法。以及 python 字符串乘法。例如:
' ' * 5 + '^' * 7
有什么帮助,谢谢!
rfind
txt = "Mi casa, su casa." // both languages
x = txt.rfind("casa") //python
x = txt.lastIndexOf("casa") //js
找到
txt = "Hello, welcome to my world." // both
x = txt.find("welcome") // pyhton
x = txt.indexOf("welcome") // js
复制
' ' * 5 + '^' * 7 // python
" ".repeat(5) + "^".repeat(7) // js
我有这个 python 代码,我想在 Javascript 中复制它,但我不知道如何执行 Python 的 rfind 或 find 方法。以及 python 字符串乘法。例如:
' ' * 5 + '^' * 7
有什么帮助,谢谢!
rfind
txt = "Mi casa, su casa." // both languages
x = txt.rfind("casa") //python
x = txt.lastIndexOf("casa") //js
找到
txt = "Hello, welcome to my world." // both
x = txt.find("welcome") // pyhton
x = txt.indexOf("welcome") // js
复制
' ' * 5 + '^' * 7 // python
" ".repeat(5) + "^".repeat(7) // js