linux下怎么编写python

linux下怎么编写python,第1张

你说的是自己写的python程序吗?python是解释性的语言,不需要编译,直接使用

python xxxx.py运行即可。

如果你说的是编译安装python,无非就是make;make install。源码包里面也会有说明的。一般linux里面有已经安装了python。

1.选择File ->Settings

2.选择 File and Code Templates ->Files ->Python Script

编辑代码的样式

#!/usr/bin/env python

# encoding: utf-8

'''

@author: caopeng

@license: (C) Copyright 2013-2017, Node Supply Chain Manager Corporation Limited.

@contact: [email protected]

@software: garner

@file: ${NAME}.py

@time: ${DATE} ${TIME}

@desc:

'''

3.新建一个python,文件如下所示

假你想写一个文件filename='/root/wujin/5.2/03.html'

但是文件夹可能不存在。

先这样子

targetpath = os.path.dirname(filename)

if not os.path.isdir(targetpath):

os.makedirs(targetpath)

然后你就可以打到filename,写入内容了。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8979713.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-23
下一篇 2023-04-23

发表评论

登录后才能评论

评论列表(0条)

保存