作为一个小白,这段内容学的很崩溃,不在于有多难,而是自己老是出错,记录一下吧
with open('test_word') as if:
File "<stdin>", line 1
with open('test_word') as if:
^
SyntaxError: invalid syntax
>>> with open('E:\lenovo\test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'E:\\lenovo\test_word'
>>> with open('/lenovo/test_eord','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/lenovo/test_eord'
>>> with open('/lenovo/test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/lenovo/test_word'
>>> with open('E:/lenovo/test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'E:/lenovo/test_word'
>>> with open('E:\lenovo\test_word.txt','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'E:\\lenovo\test_word.txt'
>>> with open('E:/lenovo/test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'E:/lenovo/test_word'
>>> with open('E:/lenovo/test_word.txt','r') as f:
... print(f.read())
...
hello,world
File "<stdin>", line 1
with open('test_word') as if:
^
SyntaxError: invalid syntax
>>> with open('E:\lenovo\test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'E:\\lenovo\test_word'
>>> with open('/lenovo/test_eord','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/lenovo/test_eord'
>>> with open('/lenovo/test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/lenovo/test_word'
>>> with open('E:/lenovo/test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'E:/lenovo/test_word'
>>> with open('E:\lenovo\test_word.txt','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'E:\\lenovo\test_word.txt'
>>> with open('E:/lenovo/test_word','r') as f:
... print(f.read())
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'E:/lenovo/test_word'
>>> with open('E:/lenovo/test_word.txt','r') as f:
... print(f.read())
...
hello,world
写了将近10遍,才终于写通。大概真的是比较笨