# coding=utf-8

import sys
class Hello(): def hello(self):
print('the name of method is ## {} ##'.format(sys._getframe().f_code.co_name))
print('the name of class is ## {} ##'.format(self.__class__.__name__)) if __name__ == "__main__":
h = Hello()
h.hello()

  

python 获取当前运行的 class 和 方法的名字的更多相关文章

  1. Python获取程序运行目录和脚本目录

    Python获取程序运行目录和脚本目录 import os import sys #获取脚本所在目录 print os.path.split( os.path.realpath( sys.argv[0 ...

  2. python 获取当前运行的类名函数名

    import inspect def get_current_function_name(): return inspect.stack()[1][3] class MyClass: def func ...

  3. Python获取脚本所在目录的正确方法(转)

    1.以前的方法如果是要获得程序运行的当前目录所在位置,那么可以使用os模块的os.getcwd()函数.如果是要获得当前执行的脚本的所在目录位置,那么需要使用sys模块的sys.path[0]变量或者 ...

  4. 编写python程序和运行.py文件的方法步骤

    前提:已安装好 Subliume Test 3 且已经添加好python编译系统,已安装好python3.7 一.新建一个文本文档,将后缀名改为.py 二.使用 Subliume Test 3 打开该 ...

  5. python 获取本机ip地址的方法(Unix 平台)

    #!/usr/bin/python import socket import fcntl import struct def get_ip_address(ifname): s = socket.so ...

  6. python 获取类中除内置方法外的所有方法名

    #!/usr/bin/env python# !-*- coding:utf-8 -*- class Menu: def __init__(self): pass def updateProject( ...

  7. python获取网页信息的三种方法

    import urllib.request import http.cookiejar url = 'http://www.baidu.com/' # 方法一 print('方法一') req_one ...

  8. python获取当前运行程序的名字

    import os filename = os.path.abspath(__file__) print filename 打印结果: E:\bluedon\test.py

  9. python 获取文件运行路径

    import os print(os.getcwd()) print("/".join(os.path.dirname(os.path.abspath(__file__)).spl ...

随机推荐

  1. Leetcode--easy系列3

    #26 Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such th ...

  2. sql 转 markdown

    https://github.com/2liang/AutoBuildDocFromDB SQL脚本生成数据字典 http://www.jianshu.com/p/f491d0d3c503 这两个脚本 ...

  3. PHP--关于模板的原理和解析(php模板原理)

    此内容用作笔记,以备日后查看,此内容为学习李炎恢课程而来,并非自己所创,如有问题请私信~ 将PHP代码和静态HTML代码进行分离,使代码的可读性和维护性得到显著提高. 使用模板引擎: 我们所说的模板是 ...

  4. Pmon (LS1B)start.s

    loongson ls1b FPGA验证 只有DDR flash UART pmon移植 和原版本相比,DDR controller和ls1b不一致. /* $Id: start.S,v 1.1.1. ...

  5. 【转载】表单验证<AngularJs>

    原文地址:http://www.cnblogs.com/rohelm/archive/2014/10/19/4033513.html 常用的表单验证指令 1. 必填项验证 某个表单输入是否已填写,只要 ...

  6. Knockout JS 演示样例

    五个小样例,来自Knockout JS官方站点. //tutorial 1 //following codes uses to demonstrate observable values and ta ...

  7. Python内置函数之eval()

    eval(expression,globals=None,locals=None) 返回表达式的值.第一个参数必须是字符串.第二个参数可选,如果有必须是字典:第三个参数可选,如果有必须是映射对象(比如 ...

  8. Unity3D - 发布Android游戏

    本文将介绍如何使用Unity3D来发布Android游戏,这里我使用的Unity3D版本为4.6.3f1 下载Java SDK 使用Unity3D来发布Android游戏时需要用到Android SD ...

  9. Yarn源码分析之MapReduce作业中任务Task调度整体流程(一)

    v2版本的MapReduce作业中,作业JOB_SETUP_COMPLETED事件的发生,即作业SETUP阶段完成事件,会触发作业由SETUP状态转换到RUNNING状态,而作业状态转换中涉及作业信息 ...

  10. Nandflash镜像尾部不应填充0xFF

    Nandflash镜像文件系统尾部经常被填充0xFF以补齐大小,这样做是错误的,可能会有意想不到的bug.包括JFFS2.UBIFS等. 因此建议丢弃多余的0xFF. 出自:http://www.li ...