我是Python的新手。我正在模拟氧化锆纳米管。在PDB中生成了结构并想将文件导出到ANSYS。下面的代码是为Python编写的:
node_value = 0
file = open('C:\\xyz\\test.pdb', 'r')
igot = file.readlines()
output_file = open('C:\\xyz\\nodes.txt', "a") # needs input for distinct file
utput_file.write('/PREP7'+"\n") #open pre-processing menu
for line in igot:
if line.find("ATOM") > -1:
node_value = node_value + 1
nv = str(node_value)
xyz = line.split()
#print kv,",", xyz[6], ",", xyz[7], ",", xyz[8]
line_i = "N" + ', '+ nv + ', ' + xyz[6] + ', ' + xyz[7] +', '+ xyz[8]+ "\n"
print (line_i)
output_file.write(line_i)
我收到一条错误消息:文件“c:\ xyz \ test.py”,第2行,中 file = open('C:\ xyz \ test.pdb','r')
builtins.FileNotFoundError:[Errno 2]没有这样的文件或目录:'C:\ xyz \ test.pdb'
如何解决问题?
答案 0 :(得分:0)
大胆猜测:没有文件'C:\ xyz \ test.pdb'