from pypinyin import pinyin, Style # The phrase to convert phrase = "农村" # Generate pinyin with tone marks pinyin_list = pinyin(phrase, style=Style.TONE) # Flatten the list and join pinyin_str = " ".join([item[0] for item in pinyin_list]) print(pinyin_str)