zoukankan      html  css  js  c++  java
  • c++打印环境变量

    直接上代码:cpp版本

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include <string.h>
     4 
     5 extern char** environ;
     6 int main(int argc, char* argv[])
     7 {
     8     printf("Content type:text/plain
    
    ");
     9 
    10     char** env = environ;
    11     while(*env){
    12         printf("===%s====
    ", *env);
    13         env++;
    14     }   
    15     printf("===end=====");
    16     fflush(stdout);
    17 
    18     return 0;
    19 }

    py版本:

    1 #!/usr/bin/python 
    2 #encoding=utf-8
    3 
    4 import os
    5 
    6 print "Content-type:text/html
    
    "
    7 print "<font size=+1>Environment</font>"
    8 for param in os.environ.keys():
    9     print "<b>%20s</b>: %s "  %(param, os.environ[param])

      c++版本中,上述示例中,需要后续解析字符串,此外使用getenv(varname)获取指定的环境变量值,前提是知道某个环境变量名(key);

  • 相关阅读:
    RoIPooling、RoIAlign笔记
    ROI Align 的基本原理和实现细节
    ROI Align详解
    GIT总结
    java-变量,函数 下
    linux设置静态ip地址
    技术参考网站-网址
    python
    python
    python
  • 原文地址:https://www.cnblogs.com/chris-cp/p/5121194.html
Copyright © 2011-2022 走看看