简体   繁体   English

在Abaqus脚本中使用Python导入模块

[英]Importing modules using Python in Abaqus script

I am trying to import the Tkinter module into my abaqus script so that I can create popup boxes. 我正在尝试将Tkinter模块导入到我的abaqus脚本中,以便创建弹出框。 I have tried appending the directory and tried both Tkinter and tkinter (although the file is Tkinter.py , I checked) Here is my code. 我曾尝试追加的目录,并试图既Tkinter的和tkinter (虽然该文件是Tkinter.py ,我选中)这是我的代码。 The path that I appended to is the folder where the Tkinter.py file is located. 我附加到的路径是Tkinter.py文件所在的文件夹。 The error that I get says ImportError: No module named Tkinter 我得到的错误是ImportError: No module named Tkinter

import sys
sys.path.append('C:\SIMULIA\Abaqus\6.12-3\tools\SMApy\Lib\lib-tk')
from Tkinter import *

'\\t' in Python represent TAB character, not a backslashed and t . Python中的'\\t'代表TAB字符,而不是反斜杠和t

If you want to represnt backslash and t , you should escape the backslash, or should use raw string literal. 如果要表示反斜杠和t ,则应转义反斜杠,或应使用原始字符串文字。

'C:\\SIMULIA\\Abaqus\\6.12-3\\tools\\SMApy\\Lib\\lib-tk'

or 要么

r'C:\SIMULIA\Abaqus\6.12-3\tools\SMApy\Lib\lib-tk'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM