此代码适用于2.7但不适用于3.5 - 我知道这与unicode兼容有关。
这是代码,任何帮助将不胜感激
import array
import sys
ConstNoStudents = int(4)
Counter = int(0)
StudentMarkTest1 = array.array("Test 1", range(ConstNoStudents + 1))
StudentMarkTest2 = array.array("Test 2", range(ConstNoStudents + 1))
StudentName = []
StudentGender = []
input_value = raw_input
while Counter <4:
gender_value = int(0)
input_value = raw_input
Counter = Counter+1
StudentName.append (raw_input("Please Enter Student Name "))
print(StudentName)
while gender_value == 0:
gender = raw_input("Please Enter Student Gender ")
if gender == 'm' or gender == 'f' or gender =='M' or gender == 'F':
StudentGender.append(gender)
gender_value = gender_value+1
StudentMarkTest1[Counter] = int(raw_input("Please Enter Mark for Test 1 "))
StudentMarkTest2[Counter] = int(raw_input("Please Enter Mark for Test 2 "))
print (StudentName )
print (StudentGender)
print (StudentMarkTest1 )
print (StudentMarkTest2 )
答案 0 :(得分:0)
JSON.stringify
这是您的代码的Python3版本,现在输入raw_input。
此外,array.array的第一个参数需要是定义数据类型的字符。