键入此命令时:
touch ./__init__.py这就是该文件在nautilus >右击__init__.py中的样子:

如您所见,它是一个文本文件,而不是py文件。
我使用的是BUUNTU18.04仿生。
如何在终端中启用文件扩展名?
发布于 2018-09-25 03:05:58
在Linux / Ubuntu中,文件扩展名实际上只用于用户方便地识别文件是什么。
使用file命令可以向您显示文件实际上应该是什么。它将读取文件的内容并告诉您它是什么。因此,当文件为空时,它只显示一个普通的文本图标。一旦它有了内容,它就会正确地显示。
示例:
terrance@terrance-ubuntu:~/tmp$ touch file.bsh
terrance@terrance-ubuntu:~/tmp$ file file.bsh
file.bsh: empty

将#!/bin/bash添加到file.bsh文件中:
terrance@terrance-ubuntu:~/tmp$ cat file.bsh
#!/bin/bash
terrance@terrance-ubuntu:~/tmp$ file file.bsh
file.bsh: Bourne-Again shell script, ASCII text executable

https://askubuntu.com/questions/1078193
复制相似问题