「Python入門」read()でcsvファイルを読み込む

2021年1月10日

test.csvファイル
A001,B002,C003,D004,E005
151,152,313,414
111,222,333,444

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# coding: utf-8
#!/usr/bin/python3
with open('C:\\pythonlesson\\test.csv') as cft:
print(cft.read())
# coding: utf-8 #!/usr/bin/python3 with open('C:\\pythonlesson\\test.csv') as cft: print(cft.read())
# coding: utf-8
#!/usr/bin/python3

with open('C:\\pythonlesson\\test.csv') as cft:
    print(cft.read())

実行結果
>python test.py
A001,B002,C003,D004,E005
151,152,313,414
111,222,333,444

Python

Posted by arkgame