【问题标题】:Powershell '>' operator, change encoding?Powershell'>'运算符,更改编码?
【发布时间】:2014-09-06 10:15:58
【问题描述】:

有没有办法改变 powershell 中 > 运算符的默认编码?我希望它为我的 requirements.txt 输出为 ANSI 为 UTF-8:

pip freeze > requirements.txt

【问题讨论】:

    标签: python windows powershell


    【解决方案1】:
    pip freeze | Out-File -Encoding UTF8 requirements.txt
    

    或者你可以试试

    pip freeze > iconv -f UTF-8 -t ISO-8859-1 in.txt > out.txt
    

    你可以阅读iconv

    【讨论】:

    • @jeff 为此尝试 ISO-8859-1
    • ut-File:无法验证参数“编码”的参数。参数“ISO-8859-1”不属于ValidateSet属性指定的集合unknown,string,unicode,bigendianunicode,utf8,utf7,utf32,ascii,default,oem”。
    • @Jeff 试试 utf-8-sig 这个。我正在了解他们。我已经搜索并看到了这个更有用的链接stackoverflow.com/questions/8898294/…
    • 我认为powershell不支持。
    • @Jeff 然后尝试在 python 中编写一个可转换的 python 代码。使用 std.in 和 std.out 将结果保存在 txt 文件中。
    猜你喜欢
    • 2020-12-20
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    相关资源
    最近更新 更多