【问题标题】:TypeError:unsupported operand type(s) for -: 'str' and 'int'类型错误:不支持的操作数类型 -: 'str' 和 'int'
【发布时间】:2015-08-31 17:37:05
【问题描述】:

我想将 pmma85compositedata.initeq 转换为可接受的 lammps 数据文件,但我遇到了这个错误:

import lmpsdata, copy
data=lmpsdata.Lmpsdata('pmma85compositedata.initeq','full')
polymer=lmpsdata.molecules(data,1,19,'atom') #'atom
nanoparticle=lmpsdata.molecules(data,20,20,'atom')
surface=lmpsdata.particlesurface(nanoparticle[0], 1.94, 8,'full')

错误:

polymer=lmpsdata.molecules(data,1,19,'atom') #'atom
File "/home/marham/...../lmpsdata.py", line 1193, in molecules
p=Pool(processors)
File "/usr/lib/python2.7/multiprocessing/__init__.py", line 232, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 159, in __init__
self._repopulate_pool()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 214, in        _repopulate_pool
for i in range(self._processes - len(self._pool)):
TypeError: unsupported operand type(s) for -: 'str' and 'int'

【问题讨论】:

    标签: python operands lammps


    【解决方案1】:

    查看the source codelmpsdata.molecules() 函数,您缺少一个参数:池中的处理器数量。试试:

    polymer = lmpsdata.molecules(data, 1, 19, 8, 'atom')
    nanoparticle = lmpsdata.molecules(data, 20, 20, 8, 'atom')
    

    ...或将8 替换为您可以使用的however many processors

    【讨论】:

      猜你喜欢
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 2018-02-05
      • 1970-01-01
      • 2017-05-27
      • 2013-10-12
      • 2014-08-10
      相关资源
      最近更新 更多