import os
def get_text(f):
with open(f) as file:
text = file.read()
return text
print(get_text(习题.txt))
Traceback (most recent call last):
File "/Users/mac/Desktop/1.py", line 6, in <module>
print(get_text(习题.txt))
NameError: name '习题' is not defined
如下:
import os
def get_text(f):
with open(f) as file:
text = file.read()
return text
print(get_text("习题.txt"))