from sys import stdin
t=int(stdin.readline())
while(t):
s=stdin.readline()
str = []
top=-1
for i in range(0, len(s)):
c=s.index(i)
if(c>='a' and c<='z'):
print(c)
elif(c=='('):
pass
elif(c==')'):
print(str[top])
top-=1
else:
top+=1
str[top] = c
t-=1
1
(a+b)
錯誤:
Traceback (most recent call last):
File "C:\Users\Anurag\AppData\Roaming\NetBeans\8.0.1\nb_test_runner.py", line 216, in <module>
module = __import__(module_name, globals(), locals(), module_name)
File "__pyclasspath__/opn.py", line 8, in <module>
Finished in 0.0 seconds.
TypeError: expected a str
0 tests, 0 failures, 0 errors
提供1
和(a+b)
如上誤差輸入得到顯示之後。
請不要用'str'作爲變量名:它的混亂,它阻止你使用內置'STR()'函數。 – 2014-10-04 10:24:15