-1
それは私が欠けているということはおそらく愚かなものだが:私はこの例外を取得してい
:これは "整数として解釈できません"というエラーの原因です。
Traceback (most recent call last):
File "P:\Programming\Python\Windows\Console\ProjectHashDec\ProjectHashDec\ProjectHashDec.py", line 29, in <module>
print(str(j) + ": " + str(int(hex(convertNumbers[j]), times)))
TypeError: 'str' object cannot be interpreted as an integer
このコードは動作しない理由を私は知らない:中
print("How many hexadecimal numbers do you want to input?")
print("A: 8")
print("B: 16")
print("C: 32")
print("D: 64")
choice = input("What do you choose? > ")
times = 0
if (choice == "A"):
times = 8
elif (choice == "B"):
times = 16
elif (choice == "C"):
times = 32
elif (choice == "D"):
times = 64`
convertNumbers = []
i = 0
j = 0
while i < times:
i += 1
convertNumbers.append(input(str(i) + ": "))
while j < times:
j += 1
print(str(j) + ": " + str(int(hex(convertNumbers[j]), times)))
あなたが書いたのは、**有効なPythonではありません。 'times = 64'には単一のバックティックがあり、これは' SyntaxError'を引き起こします。使用している実際のコードを投稿してください。いずれにしても、 'times'は実際には文字列であると推測されます。>>> int('10 '、' hello ') トレースバック[...] TypeError:' str 'オブジェクトは整数として解釈できません' – Bakuriu
[mcve]を入力してください。作成時には、おそらくあなた自身の問題を解決するでしょう。 – jonrsharpe