最近在使用最新Anaconda 4.2.0的PyQt5时报如下错:
Traceback (most recent call last):
File "/opt/package/test1.py", line 81, in <module>
File "/opt/package/test1.py", line 41, in __init__
print 6666, test(time_str)
File "/opt/sumscope/cdh/package//test1.py", line 26, in test
return datetime.datetime.strptime(time_str, '%I:%M:%S %p').strftime('%H:%M:%S')
File "/opt/anaconda/lib/python2.7/_strptime.py", line 332, in _strptime
(data_string, format))
ValueError: time data '5:45:56 AM' does not match format '%I:%M:%S %p'
这是因为Linux设置的语言环境为中文导致,修改为英文就行了
发法一:
export LANG=en_US.utf8
方法二:
修改/etc/profile文件,在该文件最后加上
export LANG=en_US.utf8
注:查看Linux语言环境命令
[root@localhost ~]# locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=