如何解决此代码第3行中的Unindent does not match any other indentation level
语法错误?
if userInput==1:
oneD()
elif userInput==2:
twoD()
elif userInput==3:
threeD()
elif userInput==4:
fourD()
elif userInput==5:
fiveD()
答案 0 :(得分:0)
它应该看起来像这样;所有均匀间隔:
if userInput==1:
oneD() #this one was not spaced evenly like the rest of your code
elif userInput==2:
twoD()
elif userInput==3:
threeD()
elif userInput==4:
fourD()
elif userInput==5:
fiveD()
答案 1 :(得分:-1)
我认为代码中的空格是混合的,请尝试修复它。
let quantity = 10;
var width : CGFloat = 0.0;
override func viewDidLoad() {
super.viewDidLoad()
width = self.scrView.frame.width;
for i in 0..<quantity {
let xPos = width * CGFloat(i);
let label = UILabel(frame: CGRect(x: xPos, y: 0, width: width, height: self.scrView.frame.height))
label.textAlignment = .center
label.font = UIFont(name: "Helvetica Neue", size: 50)
label.textColor = UIColor.white
label.text = "\(i + 1)"
label.backgroundColor = .randomColor()
scrView.addSubview(label);
}
scrView.contentSize.width = width * CGFloat(quantity + 1);
}
答案 2 :(得分:-1)
您的空间在您的代码中混合,您一直在使用标签和空格的混合。尝试使用TAB或使用普通空格来解决这个问题。