[英]Opening and Reading files in Python
出於某種原因,我無法在 python 中打開我的 .txt 文件。
我在一個文件夾中有 .py 和 .txt 文件。 這兩個文件都存儲在工作區 -> 文件夾(速成課程)-> 文件夾(課程)-> 文件夾(第 10 章)-> 兩個文件都在這個第 10 章文件夾中。
我正進入(狀態
FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'
使用代碼:
with open('pi_digits.txt') as file_object:
contents = file_object.read()
print(contents)
出於某種原因,我無法在 python 中打開我的 .txt 文件。
我在一個文件夾中有 .py 和 .txt 文件。 兩個文件都存儲在工作區 -> 文件夾(速成班)-> 文件夾(課程)-> 文件夾(第 10 章)-> 兩個文件都在這個第 10 章文件夾中。
我正進入(狀態
FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'
使用代碼:
with open('pi_digits.txt') as file_object:
contents = file_object.read()
print(contents)
出於某種原因,我無法在 python 中打開我的 .txt 文件。
我在一個文件夾中有 .py 和 .txt 文件。 兩個文件都存儲在工作區 -> 文件夾(速成班)-> 文件夾(課程)-> 文件夾(第 10 章)-> 兩個文件都在這個第 10 章文件夾中。
我正進入(狀態
FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'
使用代碼:
with open('pi_digits.txt') as file_object:
contents = file_object.read()
print(contents)
出於某種原因,我無法在 python 中打開我的 .txt 文件。
我在一個文件夾中有 .py 和 .txt 文件。 兩個文件都存儲在工作區 -> 文件夾(速成班)-> 文件夾(課程)-> 文件夾(第 10 章)-> 兩個文件都在這個第 10 章文件夾中。
我正進入(狀態
FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'
使用代碼:
with open('pi_digits.txt') as file_object:
contents = file_object.read()
print(contents)
出於某種原因,我無法在 python 中打開我的 .txt 文件。
我在一個文件夾中有 .py 和 .txt 文件。 兩個文件都存儲在工作區 -> 文件夾(速成班)-> 文件夾(課程)-> 文件夾(第 10 章)-> 兩個文件都在這個第 10 章文件夾中。
我正進入(狀態
FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'
使用代碼:
with open('pi_digits.txt') as file_object:
contents = file_object.read()
print(contents)
出於某種原因,我無法在 python 中打開我的 .txt 文件。
我在一個文件夾中有 .py 和 .txt 文件。 兩個文件都存儲在工作區 -> 文件夾(速成班)-> 文件夾(課程)-> 文件夾(第 10 章)-> 兩個文件都在這個第 10 章文件夾中。
我正進入(狀態
FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'
使用代碼:
with open('pi_digits.txt') as file_object:
contents = file_object.read()
print(contents)
您可能必須啟用“在文件目錄中執行” vscode 設置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.