Recent research on Software-Defined Networking (SDN) strongly promotes theadoption of distributed controller architectures. To achieve high networkperformance, designing a scheduling function (SF) to properly dispatch requestsfrom each switch to suitable controllers becomes critical. However, existingliterature tends to design the SF targeted at specific network settings. Inthis paper, a reinforcement-learning-based (RL) approach is proposed with theaim to automatically learn a general, effective, and efficient SF. Inparticular, a new dispatching system is introduced in which the SF isrepresented as a neural network that determines the priority of eachcontroller. Based on the priorities, a controller is selected using ourproposed probability selection scheme to balance the trade-off betweenexploration and exploitation during learning. In order to train a general SF,we first formulate the scheduling function design problem as an RL problem.Then a new training approach is developed based on a state-of-the-art deep RLalgorithm. Our simulation results show that our RL approach can rapidly design(or learn) SFs with optimal performance. Apart from that, the trained SF cangeneralize well and outperforms commonly used scheduling heuristics undervarious network settings.