时间:2019-03-22
概述:宏代码
分享几个Python 宏#define命令练习代码:
宏#define命令练习代码一:
TRUE = 1
FALSE = 0
def SQ(x):
return x * x
print 'Program will stop if input value less than 50.'
again = 1
while again:
num = int(raw_input('Please input number'))
print 'The square for this number is %d' % (SQ(num))
if num >= 50:
again = TRUE
else:
again = FALSE
宏#define命令练习代码二:
#include "stdio.h"
#define exchange(a,b) { \ /*宏定义中允许包含两道衣裳命令的情形,此时必须在最右边加上"\"*/
int t;\
t=a;\
a=b;\
b=t;\
}'
这个宏定义python不支持
'''
def exchange(a,b):
a,b = b,a
return (a,b)
if __name__ == '__main__':
x = 10
y = 20