本文整理汇总了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)