示例3:Python获取当前环境下默认编码(字符编码demo1.py)

字符编码,python解释器在加载py文件中的代码时,会对内容进行编码(默认ASCII),windows系统默认编码为GBK,Ubuntu系统下的pycharm默认为utf8。查看Ubuntu系统的默认编码方法:

python 示例代码3

python 示例代码3

示例:Python 2.x版本下的字符编码

所以为了兼容2.×版本,代码前写上# -*- coding: utf-8 -*-

python 示例代码3

相关文章:

  • 2021-10-20
  • 2021-06-11
  • 2021-11-22
  • 2022-01-08
  • 2021-12-03
  • 2021-11-03
  • 2023-01-28
  • 2021-07-28
猜你喜欢
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-02-08
相关资源
相似解决方案