python错题

1.

 

str1 = input()
s = '1234567890abcdefABCDEF'
c = ""
for item in str1:
  if item in s:
    c = c + item

# print(str1.find(c[0]))
# print(str1.find('-'))
if c == '':
  print('0')
elif str1.find(c[0])>str1.find('-'):
  print(-int(c,16))
else:
  print(int(c,16))

 

posted @ 2021-03-13 16:18  助手的fork  阅读(48)  评论(0编辑  收藏  举报