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
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
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'),