擅长:python、mysql、java
<p>使用snap7的最新设置如下所示:</p>
<ul>
<li><p>通过“pip install”在命令行中使用pip安装snap7 for python
python-snap7“</p></li>
<li><p>从<a href="https://sourceforge.net/projects/snap7/files/" rel="nofollow">sourceforge</a>下载最新的snap7包</p></li>
<li><p>将32位或64位版本复制到任何文件夹,例如项目文件夹</p></li>
<li>在python程序中执行导入snap7</li>
<li><p>在python程序中临时编辑环境变量</p>
<pre><code>#---Temporarily Change The Path Enviroment Variable For Snap7.dll---
if not snapPath in os.environ["PATH"]:
os.environ["PATH"] = os.environ["PATH"] + ";" + snapPath.replace("/","\\")
</code></pre></li>
</ul>
<p>路径中允许有空格。这很好,但如果您创建安装程序,例如使用xfreeze。</p>