Python新建模块文件为何不能重命名?

本人新手,正在学编写python的测试文件。

目的是在名为test_city.py的文件中,导入名为city_functions.py的文件的函数

但现在我新建的模块1.py文件不能重命名为city_functions.py

图片说明

文件:test_city.py

import unittest

from city_functions import form_location

class citytest (unittest.testcase):

'''测试city_functions'''

def test_city_function(self):

'''能正确把城市和国家拼在一起吗?'''

formatted_location=form_location('Changsha','China')

self.assertEqual(formated_location,'Changsha China')

文件:模块1.py(想修改为city_functions.py)

def form_location(city,country):

'''结合城市名和国家名'''

location=city+' '+country

return location

```

回答

模块1.py前面图标跟test_city.py的图标怎么不一样

要么文件没有包含在项目中(可以通过右键选择"包括在项目中"添加至项目)

要么这个文件类型有问题,可以右键项目名称,选择"添加">"添加新建项",选择python文件

以上是 Python新建模块文件为何不能重命名? 的全部内容, 来源链接: utcz.com/a/41820.html

回到顶部