私はこのエラーを取得し、このPythonコードPythonのエラー「はTypeError:型のオブジェクトは、 'NoneType'(何LENを持っていない)
def read_lines():
user_entries = []
contin = True
while contin == True:
user_input = input(str("Enter string or just press enter to finish: "))
user_entries.append(user_input)
if len(user_input) == 0:
contin = False
print(user_entries)
lines = read_lines()
print(lines)
ci = o
contin = True
while contin:
if ci == len(lines):
contin = False
else:
line = lines(ci, ci + 1)
ci = ci + 1
print(ci, line)
からエラーを取得しています...
Traceback (most recent call last):
File "test.py", line 8 in <module>
if ci == len(lines):
Type Error: object of type 'NoneType' has no len()
私はこのエラーがなぜ発生するのかよく分かりません。ラインプリント(行)を実行すると、Noneが返されます。これはおそらく問題ですが、修正方法がわかりません。
あなたが 'read_lines()'を定義した関数は 'lines'に何も返しませんので、** None **です。 – bhansa
回答を[回答済み](https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjf__iKnpnTAhXky4MKHeloBR8QFggZMAA&url=https%3A%)にすることを忘れないでください。 2F%2Fmeta.stackexchange.com%2Fquestions%2F5234%2答えを受け入れていること&usg = AFQjCNE2e2orpogybVZU_sdJD6evWbT5Fw&bvm = bv.152174688、d.amc&cad = rja) – bhansa