在为类编写一些代码时,它出现了此错误,并且我不知道如何解决它,因为我个人看不到它所解决的问题
traceback (most recent call last): File "C:\Users\Daniel Benotti\Desktop\School\Benotti_Daniel student Ed loop with functions.py", line 50, in main() File "C:\Users\Daniel Benotti\Desktop\School\Benotti_Daniel student Ed loop with functions.py", line 9, in main TotCurr, TotCe = loop(TotCurr, TotCe, again) File "C:\Users\Daniel Benotti\Desktop\School\Benotti_Daniel student Ed loop with functions.py", line 21, in loop TotCurr, TotCe, studType = calc(studNum, TotCurr, TotCe) File "C:\Users\Daniel Benotti\Desktop\School\Benotti_Daniel student Ed loop with functions.py", line 34, in calc if studNum > STUD_NUMBER: TypeError: '>' not supported between instances of 'str' and 'int'`enter code here`
这是后面的代码
content = "aba(2)bb(52)gc(4)d(2)fe(14)f(6)g(8)h(4)5(6)";
a = content.split("[a-g]|[a-g]\\([0-9]*\\)");
for (String s:
a) {
System.out.println(s);
}
答案 0 :(得分:1)
您似乎正在比较一个字符串和一个整数
执行此操作:
if int(studNum) > STUD_NUMBER:
这称为强制转换。您将使用以下函数将字符串转换为int:int()