# 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. http Referrer-Policy

    Referrer-Policy: no-referrer Referrer-Policy: no-referrer-when-downgrade Referrer-Policy: origin Ref ...

  2. 经过Nginx代理后如何区分HTTP请求头中的X-Forwarded-For和X-Real-IP,以及Java示例

    在开发工作中,我们常常需要获取客户端的IP.一般获取客户端的IP地址的方法是:request.getRemoteAddr();但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实 ...

  3. Atitit.编程语言and 自然语言的比较and 编程语言未来的发展

    Atitit.编程语言and 自然语言的比较and 编程语言未来的发展 1. 单词的间隔靠空格,编程的单词的间隔靠分界符..1 2. 语句分界符:自然语言使用逗号,编程语言使用分号1 3. 换行1 4 ...

  4. Atitit.linq java的原理与实现 解释器模式

    Atitit.linq java的原理与实现 解释器模式 1. Linq  from  where 的实现1 2. Where expr 的实现1 3. Attilax的一点变化2 4. 解释器模式的 ...

  5. websocket echo test

    http://www.websocket.org/echo.html .net websocket server http://superwebsocket.codeplex.com/ http:// ...

  6. jpeg错误打印结构

    struct jpeg_error_mgr { /* Error exit handler: does not return to caller */ JMETHOD(void, error_exit ...

  7. python模块学习之six模块

    Six:Python 2和3兼容性库 Six提供了简单的实用程序,用于覆盖Python 2和Python 3之间的差异.它旨在支持在Python 2和3中都可以进行修改的代码库. 六个只包含一个Pyt ...

  8. linux管理员工具

    htop 任务管理器 bmon 网络监控 ### 详情 --------------------------------------------------- htop 任务管理器 bmon 网络监控

  9. bonjour的使用

    os中,bonjour是一个零配置的网络服务分发服务器与客户端.   在使用bonour之前你应该明白的是,bonjour并不负责数据传输,只负责发布服务与检索服务,并在客户端获取服务端的信息.   ...

  10. FreeBSD编译安装emacs,不要用ports

    1. 解压emacs 2. 进入解压之后的目录,执行configure命令,大体配置如下: ./configure --with-x-toolkit=no --with-xpm=no --with-j ...