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

时间:2015-11-16 11:39:10

标签: python main

我有以下项目结构:

enter image description here

我希望能够使用以下命令从命令行运行我的项目:

hotel-reservation> python hotel_reservation

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

ImportError: No module named 'hotel_reservation'

我在__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是一个父目录,所以我该如何解决这个问题呢?

提前致谢。

0 个答案:

没有答案