【问题标题】:Converting PDB file to ANSYS将 PDB 文件转换为 ANSYS
【发布时间】:2013-12-14 06:06:04
【问题描述】:

我是 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'

我该如何解决这个问题?

【问题讨论】:

    标签: pdp


    【解决方案1】:

    大胆猜测:没有文件'C:\xyz\test.pdb'

    【讨论】:

    • 我已经创建了文件,但收到了另一个错误消息:文件“无”,第 2 行,在 中 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 3 -4:截断 \xXX 转义(,第 2 行)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-04
    • 1970-01-01
    • 1970-01-01
    • 2021-06-18
    • 2019-01-03
    相关资源
    最近更新 更多