【发布时间】:2016-09-29 13:41:05
【问题描述】:
您好,我是 python 新手,我遇到了这个错误:
C:\Users\Dylan Galea\Desktop\Modelling and CS>python file_handling.py
文件“file_handling.py”,第 4 行
np.savetxt(\Users\Dylan Galea\Desktop\Modelling and
CS\test.txt,twoDarray,delimeter='\t') ^ SyntaxError:行继续字符后出现意外字符
我的代码是这样的:
import numpy as np
twoDarray =np.array([[1,2,3],[4,5,6]])
np.savetxt(\Users\Dylan Galea\Desktop\Modelling and CS\test.txt,twoDarray,delimeter='\t')
有人可以帮忙吗?
【问题讨论】:
-
您需要使用引号将路径指定为字符串,即
"Users/Dylan Galea/Desktop/Modelling and CS/test.txt"。请注意,\需要像\\一样转义,如果您的路径以\或/开头,则它应该是绝对的。