Discuss / Python / 请问有人遇见过复制粘贴代码到ubuntu后,代码变乱码的问题吗?

请问有人遇见过复制粘贴代码到ubuntu后,代码变乱码的问题吗?

Topic source

我用的是windows系统,想下载一个linux shell,听说现在可以直接在windows系统上下载ubuntu,就根据https://itsfoss.com/install-bash-on-windows/下载了一个。就是去microsoft store里面搜索并且下载了ubuntu。

我复制了代码

import os

print('Process (%s) start...' % os.getpid())
# Only works on Unix/Linux/Mac:
pid = os.fork()
if pid == 0:
    print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))
else:
    print('I (%s) just created a child process (%s).' % (os.getpid(), pid))

但是粘贴过去后就变成了乱码

Python 3.8.10 (default, Jun  2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>>
>>> print('Process (%s) start...' % os.getpid())
Process (207) start...
>>> # Only works on Unix/Linux/Mac:
>>> pid = os.fork()
>>> if pid == 0:
>>> ... pcs (s n yprn s%.'%(sepd) sgtpd))else:
  File "<stdin>", line 1
  File "<stdin>", line 2
    print('I am child roes%)adm aeti s  o.gti(,o.epi()
    pcs (s n yprn s%.'%(sepd) sgtpd))else:
    ^
    ^
IndentationError: unexpected indent
IndentationError: expected an indented block
>>>  rn(I(s utcetdacidpoes(s.  o.epd) i)

请问有大神遇见过这种问题吗?这是系统编码的问题还是现在microsoft store里面的ubuntu还不成熟啊?谢谢了!


  • 1

Reply