我想使用重定向附加>>或写入>来写入txt文件,但是当我这样做时,我收到了奇怪的格式“ \ x00a \ x00p ...”。
我成功使用了set-content和add-content,为什么它们按预期运行,但>>和>重定向运算符却没有运行?
使用Powershell'cat'以及简单的python打印显示输出。
rocket_brain> new-item test.txt
rocket_brain> "appended using add-content" | add-content test.txt
rocket_brain> cat test.txt
appended using add-content
Run Code Online (Sandbox Code Playgroud)
但是如果我使用重定向附加>>
rocket_brain> "appended using redirect" >> test.txt
rocket_brain> cat test.txt
appended using add-content
a p p e n d e d u s i n g r e d i r e c t
Run Code Online (Sandbox Code Playgroud)
简单的python脚本:read_test.py
with open("test.txt", "r") as file: # open test.txt in readmode
data = file.readlines() # append each line to the …Run Code Online (Sandbox Code Playgroud)