一. 使用模块
引入sys模块,使用import
#!/usr/bin/env python
# -*- coding: utf-8 -*-
' a test module '
__author__ = 'Michael Liao'
import sys
def test():
args = sys.argv
if len(args)==1:
print...
分类:
编程语言 时间:
2015-02-01 10:53:18
阅读次数:
231
1 #include "unp.h" 2 3 int 4 main(int argc, char **argv) 5 { 6 union { 7 short s; 8 char c[sizeof(short)]; 9 } un;10 11 ...
分类:
其他好文 时间:
2015-01-31 14:29:45
阅读次数:
245
对于默认构造函数,知道应该这么用:classType objectName;
估计你知道不能classType objectName();因为这是函数声明而不是类对象定义,很多资料都已提及。
但是稍微变化一下,就未必一下子反应过来了,看下面这个例子:
struct IntTest
{
int ival;
};
int _tmain(int argc, _TCHAR* argv[])
...
分类:
其他好文 时间:
2015-01-31 10:42:52
阅读次数:
181
问题:编写一个主函数main,使用两个值作为实参,并输出它们的和。代码:#include #include using namespace std;//计算两个数的和int main(int argc, char **argv){ string strName = argv[0]; int ...
分类:
编程语言 时间:
2015-01-30 22:15:17
阅读次数:
220
python中import包
1 from import语句
如果你想要直接输入argv变量到你的程序中(避免在每次使用它时打sys.),那么你可以使用from sys import argv语句。如果你想要输入所有sys模块使用的名字,那么你可以使用from sys import *语句。这对于所有模块都适用。
2 导入modules的两种方式import与from...import的...
分类:
编程语言 时间:
2015-01-30 21:09:18
阅读次数:
400
*号作为python脚本的传入参数时,必须用单引号'',才能正确传入。如python test.py 2014 '*' age
python test.py 2014 * age是错误的。
比如
test.py脚本如下
import sys
hdfs_report_historical_year = sys.argv[1]
# eg:2014-05,2014-12,...
分类:
编程语言 时间:
2015-01-30 19:42:54
阅读次数:
218
#include "apue.h"
#include int main(int argc, char *argv[])
{ fprintf(stderr, "EACCES: %s\n", strerror(EACCES)); errno = ENOENT; perror(argv[0]); exit...
分类:
其他好文 时间:
2015-01-29 21:04:21
阅读次数:
160
#include "apue.h"#include int main(int argc, char* argv[]){ DIR* dp; struct dirent* dirp; if (argc != 2) err_quit("usage: ls directory...
分类:
其他好文 时间:
2015-01-29 09:16:48
阅读次数:
139
2015.1.23//循环(计算某个数的位数) 输入一个正整数, 计算这个正整数的位数//int main(int argc, const char * argv[]) {// int n;// int cnt=0;// scanf("%d", &n);// while (n) {// ...
分类:
移动开发 时间:
2015-01-28 21:13:36
阅读次数:
448
//单分支结构//if(条件表达式)//{// 执行语句;//}/*int main(int argc, const char * argv[]) { int score; scanf("%d",&score); //纠错处理 if (score100) { return -1; ...
分类:
移动开发 时间:
2015-01-28 21:06:06
阅读次数:
263