python什么意思h_python生成.h和.m文件

import random

import os

import string

first = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

second = "abcdefghijklmnopqrstuvwxyz"

number = "345"

index = 0

array = []

#for i in range(500):

for i in range(30):

final=(random.choice(first))

index = random.randint(3, 5)

for i in range(index):

final+=(random.choice(second))

final += (random.choice(first))

for i in range(index):

final+=(random.choice(second))

array.append(final)

print (array)

# -*- coding: utf-8 -*-

# .h

def text_createH(fileNmae,msg,msg1,propertyNumber,methodArray,msg3):

full_path = 'G:/py_ios_test/t/' + fileNmae + '.h'

file = open(full_path, 'w')

#file.write('//\n// '+fileNmae+'.h\n// SajiaoShopping\n\n\n\n')

file.write('//\n// '+fileNmae+'.h\n//\n')

file.write(msg)

file.write(msg1)

propryNameArray = []

for index in range(1,propertyNumber):

propryNameArray.append(random.choice(array))

propryNameArray = list(set(propryNameArray))

for propertyName in propryNameArray:

file.write('@property(nonatomic,strong)'+random.choice(classArray)+' * '+propertyName+';\n')

file.write('\n\n')

for methodName in methodArray:

file.write('- (void)pushTo'+methodName+'VC:(NSDictionary *)info;\n')

file.write(msg3)

file.close()

print('Done')

# .m

def text_createM(fileNmae,msg,msg1,methodArray,msg3):

full_path = 'G:/py_ios_test/t/' + fileNmae + '.m'

file = open(full_path, 'w')

#file.write('//\n// '+fileNmae+'.h\n// SajiaoShopping\n\n\n\n')

file.write('//\n// '+fileNmae+'.h\n//\n')

file.write(msg)

file.write(msg1)

for methodName in methodArray:

file.write('- (void)pushTo'+methodName+'VC:(NSDictionary *)info\n{\n\n NSMutableArray *array = [NSMutableArray array];\n')

number = random.randint(3, 10)

for i in range(1,number):

file.write(' [array addObject:@"'+random.choice(array)+'"];\n')

file.write('\n}\n\n')

file.write(msg3)

file.close()

print('Done')

classArray = ['NSString','UILabel','NSDictionary','NSData','UIScrollView','UIView']

#array = ['HwxrFvrj', 'QnzduQbtdd', 'PvcrwLtqhf', 'UvdhDbjn', 'SuntmyTxvyzg', 'CvlxwBipbp', 'GzrdyzIbimvz', 'CqsjqMmgsp', 'OxaaeuWjhasc', 'NjiardRvwgbi', 'NcculmLtpljq', 'ApoqQrll', 'GkgokDyvjb', 'EblldkVouplj', 'KfdrFvnw', 'SfhyhObftc', 'SmruByoc', 'YzcccvXmpmit', 'OmqvaHpxat', 'XzytsUyvyd', 'MjforNnnyi', 'ZvjhuIdogs', 'BzfrxzSeahxc', 'PycycwFjtpny', 'XvngtoSedljr', 'DktiaCbucd', 'AqbplNuodc', 'MzkvgZuala', 'KdwzIoej', 'AaynatUpqcfd', 'IyvwhZvtjc', 'UmijGmsy', 'AoayndXxghym']

array = list(set(array))

for name in array:

number = random.randint(3, 10)

methodArray = []

for i in range(1,5):

methodArray.append(random.choice(array))

methodArray = list(set(methodArray))

#zname = name + 'ViewController'

zname = name + 'VCtr'

text_createH(zname, '#import \n','@interface '+zname+ ':'+ 'UIViewController\n\n',number,methodArray,'\n\n@end')

text_createM(zname, '#import "'+zname+'.h"\n\n' '@interface '+ zname+'()\n\n @end\n\n','@implementation '+zname+'\n\n- (void)viewDidLoad { \n\n [super viewDidLoad];\n\n}\n\n',methodArray,'\n\n@end')

参考地址:https://blog.csdn.net/u013857988/article/details/79582697#comments

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值