不使用内置函数,如何将字符串转换为整形
def convert_to_int(str):
s = 0
for i in str:
s *= 10
tmp = ord(i) - ord('0')
s += tmp
return s
val = convert_to_int("1234")
print(val, type(val)) #1234 <class 'int'>