Python:如何从lin命令运行模块

2024-04-20 05:07:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下项目结构:

enter image description here

我希望能够从命令行运行我的项目,方法如下:

hotel-reservation> python hotel_reservation

但是,执行此操作时,我收到以下错误:

^{pr2}$

我在__main__.py中的代码如下:

from hotel_reservation.utils import get_client_type_and_dates
from hotel_reservation.hotel import Hotel
from hotel_reservation.hotel_reservation_system import HotelReservationSystem


def main():
    # CODE
if __name__ == "__main__":
    main()

我想我缺少了如何指示python hotel_reservation是父目录,那么如何解决这个问题?在

提前谢谢。在


Tags: 项目方法代码命令行frompyimportget