小编Ste*_*dle的帖子

dateutil.parser.parse()在Windows平台上给出错误"initial_value必须是unicode或None,而不是str"

我确信这有一个非常简单的解决方案,但我仍然是Python的新手.

我正在尝试使用dateutil.parser.parse()来解析带有时间戳的字符串:

>>> import dateutil.parser
>>> a = dateutil.parser.parse("2011-10-01 12:00:00+01:00")
>>> print a
2011-10-01 12:00:00+01:00
Run Code Online (Sandbox Code Playgroud)

这在我的Linux服务器上工作正常,但在我的Windows测试框中它会出错:

>>> import dateutil.parser
>>> a = dateutil.parser.parse("2011-10-01 12:00:00+01:00")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\python_dateutil-2.0-py2.7.egg\dateutil\parser.py", line 698, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "C:\Python27\lib\site-packages\python_dateutil-2.0-py2.7.egg\dateutil\parser.py", line 302, in parse
    res = self._parse(timestr, **kwargs)
  File "C:\Python27\lib\site-packages\python_dateutil-2.0-py2.7.egg\dateutil\parser.py", line 350, in _parse
    l = _timelex.split(timestr)
  File "C:\Python27\lib\site-packages\python_dateutil-2.0-py2.7.egg\dateutil\parser.py", line 144, in split
    return list(cls(s))
  File "C:\Python27\lib\site-packages\python_dateutil-2.0-py2.7.egg\dateutil\parser.py", line 44, in __init__
    instream = StringIO(instream) …
Run Code Online (Sandbox Code Playgroud)

python python-dateutil

6
推荐指数
1
解决办法
9280
查看次数

easy_install M2Crypto在Windows平台上失败

我试图在Windows XP平台上安装M2Crypto.我安装了Python,easy_install和SWIG,但是当我尝试easy_install M2Crypto获取以下内容时:

SWIG\_m2crypto.i(31) : Error: Unable to find 'openssl\opensslv.h'
SWIG\_m2crypto.i(45) : Error: Unable to find 'openssl\safestack.h'
SWIG\_evp.i(12) : Error: Unable to find 'openssl\opensslconf.h'
SWIG\_ec.i(7) : Error: Unable to find 'openssl\opensslconf.h'
error: Setup script exited with error: command 'swig.exe' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

我在别处读过人们建议的内容easy_install openssl-devel,但这只是告诉我没有找到包含该名称的软件包.该名称是否区分大小写(我尝试了各种排列而没有成功),或者该建议不适用于Windows?

我不是在寻找M2Crypto的替代品.我正在挑选一些使用它的现有代码,所以我需要让我的开发环境能够运行已经编写的代码.

windows openssl easy-install m2crypto

4
推荐指数
1
解决办法
4952
查看次数