Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python、Fabric和Windows命令行在输入过程中添加奇怪的^@(插入符号at)符号_Python_Windows_Cmd_Fabric - Fatal编程技术网

Python、Fabric和Windows命令行在输入过程中添加奇怪的^@(插入符号at)符号

Python、Fabric和Windows命令行在输入过程中添加奇怪的^@(插入符号at)符号,python,windows,cmd,fabric,Python,Windows,Cmd,Fabric,我有一个远程Ubuntu服务器VPS,我通过fabric连接并执行命令 我使用Windows PC连接到此远程VPS,使用以下命令: @task def git_pull(): """ """ run("cd ~/{}/; git pull".format(env.repo_name)) 当我运行这个命令时,它提示我写Git的登录名和密码 当我尝试输入它们时,它会这样写: (virtualenv) D:\path\to\project\fabfile>fab co

我有一个远程Ubuntu服务器VPS,我通过fabric连接并执行命令

我使用Windows PC连接到此远程VPS,使用以下命令:

@task
def git_pull():
    """
    """
    run("cd ~/{}/; git pull".format(env.repo_name))
当我运行这个命令时,它提示我写Git的登录名和密码

当我尝试输入它们时,它会这样写:

(virtualenv) D:\path\to\project\fabfile>fab common.git_pull
[1.2.3.4] Executing task 'common.git_pull'
[1.2.3.4] run: cd ~/project/; git pull
[1.2.3.4] out: Username for 'https://git.example.com': u^@s^@e^@r^@
正如您所看到的,当我尝试编写
user
时,它以
u^@s^@e^@r^@

它在
^@
符号处附加了这个奇怪的插入符号

为什么windows fabric会附加这些奇怪的
^@
符号

是因为织物使用了
paramiko


我认为发生这种情况是因为不同的编码,我使用了
chcp
命令,它仍然会附加这些额外的符号。

^@
为空字符显示,即在每个字母后面附加一个空字节。看起来字符串
user
不是使用十六进制值
75 73 65 72
将ASCII编码为四个字节,而是使用十六进制值
75 00 73 00 65 00 72 00
将UTF-16编码为八个字节。或者这四个字母作为四个以null结尾的字符串一个接一个地发送。@Mofi这是windows的cmd问题吗?我没有让您的环境在运行Ubuntu的计算机上使用VPS通道和结构从windows PC连接。所以我帮不了你。根据为用户帐户配置的国家/地区,Windows cmd通常使用带有OEM代码页的单字节/字符文本编码。我认为这个问题是由Ubuntu服务器和Windows客户端之间的数据传输引起的,而不是由Windows cmd本身引起的。Windows cmd可以使用Unicode(UTF-16)的
/U
启动,输出到文件或此处使用的管道中。但是在启动
cmd.exe
时,默认情况下不使用
/U
。您可以使用免费的系统内部构件来了解这里到底发生了什么。通过在日志中右键单击进程
cmd.exe
,在属性的上下文菜单中单击,并在命令行上查看进程选项卡,可以使用进程监视器查看用于启动
cmd.exe
的命令行。