最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]CentOS中判断检测一个Python文件的编码

CentOS crifan 2173浏览 0评论

折腾:

[已解决]SQLAlchemy中添加枚举类型字段

期间,需要去搞清楚一个python的文件,本身的文件的编码是什么

确保转换为utf-8

centos detect file encoding

utilities – How can I test the encoding of a text file… Is it valid, and what is it? – Unix & Linux Stack Exchange

(SIPEvents) ➜  SIPEvents file migrations/versions/008986972eeb_.py -i 
migrations/versions/008986972eeb_.py: text/x-python; charset=utf-8

moreutils

shell – How to find encoding of a file in Unix via script(s) – Stack Overflow

Determine and change file character encoding | mindspill.net

HowTo : Determine and Change File Character Encoding | Linux Commands

linux – How to auto detect text file encoding? – Super User

[总结]

可以通过:

file -i your_file_name

去检测文件的基本信息,其中包括字符编码charset

比如:

file migrations/versions/008986972eeb_.py -i
migrations/versions/008986972eeb_.py: text/x-python; charset=utf-8

转载请注明:在路上 » [已解决]CentOS中判断检测一个Python文件的编码

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.181 seconds, using 22.14MB memory