Browse Source

更新 'b.py'

hzhu 7 years ago
parent
commit
96a1ef4878
1 changed files with 21 additions and 5 deletions
  1. 21 5
      b.py

+ 21 - 5
b.py

@@ -1,8 +1,24 @@
1 1
 import re
2 2
 s=[]
3
-o1=input('')
3
+o1=raw_input()
4 4
 s.append(o1)
5
-o2=raw_input('')
6
-s.append(o2)
7
-o3=re.split('\s',s)
8
-print o3
5
+o2=raw_input()
6
+o3=list(o2)
7
+o4=s+o3
8
+if '+' in o4:
9
+    a=o4.index('+')
10
+elif '-' in o4:
11
+    a=o4.index('-')
12
+elif '*' in o4:
13
+    a=o4.index('*')
14
+elif '/' in o4:
15
+    a=o4.index('/')
16
+if o4[a] == '+':
17
+    o=float(o4[a-2])+float(o4[a-1])
18
+elif o4[a] == '-':
19
+    o=float(o4[a-2])-float(o4[a-1])
20
+elif o4[a] == '*':
21
+    o=float(o4[a-2])*float(o4[a-1])
22
+elif o4[a] == '/':
23
+    o=float(o4[a-2])/float(o4[a-1])
24
+print o