Chinese garbled characters when Abaqus runs the script print

Garbled characters appear when the script prints out

Run the script and want to directly output the displacement data, but found that Chinese characters are garbled.

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#coding=utf-8

a = '位移数据为:0.25555'
print(a)

Running the above code produces the following
insert image description here

Solution

Use UTF-8 to decode the printed content, and then use GB2312 to encode.

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#coding=utf-8

a = '位移数据为:0.25555'

print(a.decode('utf-8').encode('GB2312'))

Run the code as shown below
insert image description here

Abaqus comes with a Chinese display of the plug-in menu

Open the ***_plugin.py file under the plugin menu and add the following code at the beginning

#!/usr/bin/python
#-*-coding: UTF-8-*-
#-*-coding: mbcs -*- 

The menu name is 'Plugin', change the buttonText parameter to the following code and it will be successful! ! !

buttonText='插件'.decode('utf-8').encode('GB2312'), 

Guess you like

Origin blog.csdn.net/weixin_53927706/article/details/127670256