The invention discloses compounds represented by a general formula (I) shown in the description, wherein in the formula (I), A and B are respectively a six-membered cyclic compound containing D1, D2,D3 and D4 and a six-membered cyclic compound containing D5, D6, D7 and D8. The invention also disclose an indoleamine-2,3-dioxygenase and/or tryptophan-2,3-dioxygenase inhibitor containing the above compounds and the application of the compounds in preparation of medicaments for treating cancers. The compounds provided by the invention can effectively inhibit cell proliferation, and have good therapeutic effects on various diseases such as the cancers, significant therapeutic effects on breast cancer, cervical cancer, colon cancer, lung cancer, stomach cancer, rectal cancer, pancreatic cancer,brain cancer, skin cancer, oral cancer, prostate cancer, bone cancer, kidney cancer, ovarian cancer, bladder cancer, liver cancer, fallopian tube tumors, ovarian tumors, peritoneal tumors, stage IV melanoma, glioma, neuroblastoma, hepatocellular carcinoma, mastoid renal tumors, head and neck tumors, leukemia, lymphoma, myeloma and non-small cell lung cancers, and very broad application prospects.