From 2c160f31c511429053e33f9c8216e49d90b98360 Mon Sep 17 00:00:00 2001 From: zhaohanyan Date: Thu, 22 Feb 2024 12:05:47 -0500 Subject: [PATCH] =?UTF-8?q?Update=20kama55.=E5=8F=B3=E6=97=8B=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加python解法,已在kama上测试通过 --- problems/kama55.右旋字符串.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/problems/kama55.右旋字符串.md b/problems/kama55.右旋字符串.md index 17c97eaa..38e37322 100644 --- a/problems/kama55.右旋字符串.md +++ b/problems/kama55.右旋字符串.md @@ -211,7 +211,17 @@ public class Main { ``` ### Python: +```Python +#注意:python中字符串是不可变的,所以使用python一定要创建新的字符串 +#获取输入的数字k和字符串 +k = int(input()) +s = input() + +#通过切片反转第一段和第二段字符串 +s = s[len(s)-k:] + s[:len(s)-k] +print(s) +``` ### Go: ```go