許意. 发表于 2022-11-10 17:08:15

python中在桌面上创建文件

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgsAAABeCAYAAACtg1ejAAAY/ElEQVR4Ae2dz48kyVXH4//JO5IlJMQBGZBYLKO0LPHDsmWthG3cjYXdWGAoOHAAMfSBA+vrzqlO5rC20bIIZDOsbNDimur90dPNdHdNT1fP9GX/gociIiPrZWT8yszIruyqb0uljIx470XEJzIjXkZEZou71ze0vnlBq6vndH72MZ0sF3R4+E166623CH8gAAIgAAIgAAIgIO5erWn98ppWl8/p/NkndPJ0QYcHB3AWcG2AAAiAAAiAAAgoAuL17Su6uX5JVxeXdHb6jJaLp3AWpnpxzEsS5XyqpUO5QAAEQGBnCMxLQcVsuTP1GVoR8Xp9Rzcv1nT1fEVnn5zTcnFChweHD3ZmQTawEJvfzjS2dBREQe1rd07lXJD48YyWtKTZjwWJeUnDXQptqzhx3yzzJzKfza8ltypVeiteXrFVmtEvV0Mv46noj9UW+eqn7o9RHM5cdc9lJx+zsSx520Ld61MYqLbTFtG+ZXCDJNZrOaNCCBrldhlch/s3IF7dvqaX1zd0eXFFz07P6OliSQcP1FlYzgoSIsdAef8NEc5xTqXwdR7Vhf9Euwf6RsvAQA3objvLkyLukISchbqyuuyjOwuButRFSQlE7YzUFillS5TxDlCJ+n6xXHXPZcdf0qmkeNtias5Cjr4leu/oVknqWyINaDsb+kGKK3W4xlRbuPtBbnEfwmJ9e0svrq/p+cUFfXJ6SovFgg5iexaWM3okCnrX/dCpueWS6dAK3puvg40piqp6FXLmwPVXzSbkuKGZeXnDOWcFiEjdjFV+TKVHUN+0u+MsjNMWPcB6Vca7R3LVPZcdL4LJJIzXFrmqmLEtEp2FoX2L0lezrIZBsw46thmndLyzsUuaFQLLv0Qk1q9e0YuXL+n55SV98uwZLZ4+jTsLRLQoBR0JQY8D8925ZEyzh4+72qh6VsE/Fda88JVn3rhZwtScqZ/OqJgXNPvUldrMzyWRHrfbzkKWtkiHmSQ53gDVvC761z2XnS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后但是创建的文件却不在桌面上,要怎么利用python在桌面上创建文件呢?

jackz007 发表于 2022-11-10 17:25:37

本帖最后由 jackz007 于 2022-11-10 17:31 编辑

            让你的 .py 源代码文件在桌面运行,它所产生的文件就会在桌面上。
            在桌面上新建一个 .py 文件
import os
os . startfile('CMD')
             把文件保存到桌面,命名为 "00.CMD.py",只要用鼠标双击这个文件,就会产生一个路径为桌面的 CMD 窗口,今后,你就可以在 CMD 窗口中运行你的代码文件了
Python x.py

許意. 发表于 2022-11-10 18:16:22

jackz007 发表于 2022-11-10 17:25
让你的 .py 源代码文件在桌面运行,它所产生的文件就会在桌面上。
            在桌面上新建 ...

就是说如果我创建一个普通文件,就.txt这种的呢?
页: [1]
查看完整版本: python中在桌面上创建文件