cover-img
avatar

QOOEO Blog

Tech Explorations & Insights

A blog about programming, tech, and software development

pydev template

pydev 使用模板新建代码

新建模板

使用模板创建文件

例子:

接受命令行参数: my argparse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
'''
${module} -- ${shortdesc}

${module} -- ${description}

@author: user name
@copyright: .com All rights reserved.
@contact: @email.com
@created: ${date}
'''

import sys
import os
import re
import json
import argparse
import platform

#===============================================================================
# get_args : 获得命令行参数
#===============================================================================
def get_args():
if len(sys.argv) == 1:
print ("place use:\npython3 %s -h" % sys.argv[0])
#sys.exit(0)

parser = argparse.ArgumentParser(description=u'')
parser.add_argument('--init', help=u"init default=False", default="False", choices=["True", "False"], required=True)
args = parser.parse_args()
args.init = True if args.init == "True" else False
return args

if __name__ == "__main__":
args = get_args()

类: Module: Class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
'''
${module} -- ${shortdesc}

${module} -- ${description}

@author: user name
@copyright: .com All rights reserved.
@contact: @email.com
@created: ${date}
'''

import sys
import os
import json

class ${MyClass}(${object}):
'''
${classdocs}
'''
def __init__(self, ${params}):
'''
${Constructor}
'''
${cursor}

声明: Content created by Jack Yang. Please keep the source link if you want to share.