我正在嘗試將a, b, c,轉換d為整數,但是在我嘗試這樣做之后,它們仍然以字串的形式出現。我試過使用回圈而不是map,但這也不起作用。
inputs = input()
split_input = inputs.split()
a, b, c, d = split_input
split_input = list(map(int, split_input))
uj5u.com熱心網友回復:
只需交換最后兩行:
split_input = list(map(int, split_input))
a, b, c, d = split_input
除非您split_input以后需要,否則根本不需要串列轉換:
split_input = map(int, split_input)
a, b, c, d = split_input
# OR in fact simply
a, b, c, d = map(int, split_input)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/346962.html
