With the rapid development and wide application of digital technology, the development dividends released by the digital economy have become increasingly prominent. Existing literature studies have shown that the development of digital finance has significantly promoted enterprise innovation by alleviating corporate financing constraints. However, the market mechanism and government role of digital finance in alleviating corporate financing constraints are rarely explored from the perspective of capital sources, and there is a lack of relevant empirical evidence. This paper believes that in the path of digital finance to promote enterprise innovation by alleviating financing constraints, market mechanisms and government regulation and control play a role at the same time, and uses commercial credit and government subsidies as proxy variables reflecting market mechanisms and government roles for theoretical discussion and empirical testing. The development of digital finance will reduce the degree of information asymmetry between enterprises and between governments and enterprises, which will help enterprises obtain higher business credit and government subsidies, thereby better meeting the capital needs of enterprise innovation and promoting enterprise innovation activities. In contrast, government subsidies have a more direct and effective role in promoting enterprise innovation than commercial credit, and their positive intermediary effect in the promotion of enterprise innovation by digital finance is usually stronger than commercial credit; the intermediary effect of commercial credit will change due to changes in the market environment, which is stronger when the macro economy is rising and the market is expanding; the intermediary effect of government subsidies is affected by the government’s development strategy, which is stronger as the government attaches greater importance to and encourages innovation; state-owned enterprises are more likely to obtain more commercial credit than non-state-owned enterprises, and large enterprises are more likely to obtain more commercial credit than small and medium-sized enterprises, so the intermediary effect of commercial credit may be relatively stronger among state-owned enterprises and large enterprises; the enterprise heterogeneity of the government subsidy intermediary effect is related to the preference of government subsidies, and the government is more inclined to support the innovative activities of what kind of enterprises, and the intermediary effect of government subsidies is stronger in this type of enterprise. The empirical analysis results of the data of A-share listed companies in Shanghai and Shenzhen stock exchanges from 2012 to 2020 support the above views. Compared with the existing literature, this paper discusses the mechanism of digital finance to promote enterprise innovation based on the market mechanism of capital allocation and government regulation, and compares and analyzes the intermediary effect of commercial credit and government subsidies, expands the research perspective in the field of digital finance from the perspective of capital allocation, and also deepens the research of resource allocation mechanism (the relationship between the market and the government) from the perspective of digital finance. This paper finds that there are two ways of improving the allocation of capital of enterprises by digital finance: market mechanism and government regulation. Furthermore, the promotion of digital finance to enterprise innovation has two paths: market power and government role. Therefore, while actively promoting the healthy development of digital finance, it is necessary to further improve the market mechanism, tap and give play to the sharing and inclusive advantages of digital finance, so that all economic entities can enjoy the dividends brought by the optimization of capital allocation equally in the unified large market;moreover, it is necessary to better play the role of the government, continue to implement the innovation-driven development strategy in depth, and strengthen the pertinence, orientation and signal of government subsidies and policy preferences.