Python无效语法为什么?c

时间:2018-06-12 17:09:56

标签: python python-2.7 syntax syntax-error spyder

为什么这个语法无效?

if 0.9*x < d[o] < 1.1*x:

这是整个代码

def phipsd(d,p):
   a=[]
   lend = len(d)
   ad=np.array(d)
   for i in range(0,9):
       for o in range(0, len(d)):
           x = (500/(2**(i))*10**-6                 
           if 0.9*x < d[o] < 1.1*x:
               c = c + p[o]
       a.append([])
       b=a[i]
              b.append(c)

2 个答案:

答案 0 :(得分:0)

您引用的行不是错误的来源。这一行是:

class ViewController: UIViewController {

  @IBOutlet weak var userMenu: UserMenu!

  override func viewDidLoad() {
    super.viewDidLoad()
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
  }

  @IBOutlet weak var button: UIButton!
  @IBAction func button(_ sender: Any) {
    print("Tapped Button")
    userMenu.ShowMe()
  }
}

请注意括号不匹配。

答案 1 :(得分:0)

def phipsd(d,p):
   a=[]
   lend = len(d)
   ad=np.array(d)
   for i in range(0,9):
       for o in range(0, len(d)):
           x = (500/(2**(i))*10**-6    # Here is a SyntaxError, Because You've started 3 parentheses but terminated only 2. So, add a closing parenthesis in the right place.             
           if 0.9*x < d[o] < 1.1*x:
               c = c + p[o]
       a.append([])
       b=a[i]
       b.append(c)

参见评论