本文整理匯總了Python中misc.Misc.string_to_array方法的典型用法代碼示例。如果您正苦於以下問題:Python Misc.string_to_array方法的具體用法?Python Misc.string_to_array怎麽用?Python Misc.string_to_array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類misc.Misc
的用法示例。
在下文中一共展示了Misc.string_to_array方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: terminate_ec2
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import string_to_array [as 別名]
def terminate_ec2(self):
"""
This function is a wrapper for parsing arguments and printing for ec2 instance termination
Tested
:return:
"""
a = awsrequests(session=self.account_information['session'])
parser = argparse.ArgumentParser(description='creation of ec2 instance', usage='''kerrigan.py ec2 create_ec2 [<args>]]
''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
parser.add_argument('--dry_run', action='store_true', default=False, help="For testing purpose only")
parser.add_argument('--instanceids', action='store', required=True,
help="A comma seperated list of instance id-s")
args = parser.parse_args(sys.argv[3:])
instanceids = Misc.string_to_array(string=args.instanceids, split_char=",")
result = a.terminate_instance(dryrun=args.dry_run, instanceids=instanceids)
logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
tablevar=self.account_information['logger_arguments']['table'])
示例2: test_string_to_array_nothing_to_split
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import string_to_array [as 別名]
def test_string_to_array_nothing_to_split(self):
string = "test"
should_be = ['test']
result = Misc.string_to_array(string=string)
self.assertEqual(should_be, result)
示例3: test_string_to_array_special_char
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import string_to_array [as 別名]
def test_string_to_array_special_char(self):
string = "test_test2_test3"
should_be = ['test', 'test2', 'test3']
result = Misc.string_to_array(string=string, split_char="_")
self.assertEqual(should_be, result)
示例4: test_string_to_array_default
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import string_to_array [as 別名]
def test_string_to_array_default(self):
string = "test.test2.test3"
should_be = ['test', 'test2', 'test3']
result = Misc.string_to_array(string=string)
self.assertEqual(should_be, result)