阅读.txt文件错误消息

时间:2018-02-20 10:50:26

标签: python

我试图通过以下代码从txt文件中读取sql脚本:

with open ("Mypath\\myfile.txt", "r") as myfile:
     data = myfile.read().replace('\n','')

我收到此错误消息:

IndentationError: expected an indented block

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

你必须正确缩进:

with open("Mypath\myfile.txt", "r") as myfile:
    data = myfile.read().replace('\n', ' ')