擅长:python、mysql、java
<p>您已将变量命名为<code>str</code>—与用于转换为字符串的内置函数同名。您需要重命名它,请尝试以下操作:</p>
<pre><code>import re
class Solution:
def rearrange(self, str_in):
# Write your code here
if str_in == "":
return str_in
sum = 0
letter = []
for i in range(len(str_in)):
if re.search("([A-Z])", str_in[i]):
letter.append(str_in[i])
else:
sum += int(str_in[i])
letsort = sorted(letter)
letstr = "".join(letsort)
result = letstr + str(sum)
return result
</code></pre>