你好,我是新来的蟒蛇,我遇到这个错误:文件在Python处理初学者
C:\Users\Dylan Galea\Desktop\Modelling and CS>python file_handling.py
File "file_handling.py", line 4
np.savetxt(\Users\Dylan Galea\Desktop\Modelling and
CS\test.txt,twoDarray,delimeter='\t') ^ SyntaxError: unexpected character after line continuation character
我的代码是这样的:
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/Modeling and CS/test.txt”。请注意,'\'需要像'\\'一样转义,如果你的路径以'\'或'/'开头,它应该是绝对的。 –