# -*- coding: utf-8 -*- """ Python ver2.7.13 [ string_sample.py ] Author kazuki tanaka Create Date 2017 4/20 """ # -*- Start Python -*- # both '' or "" , do using string print 'sample' print "sample" # Multi Line Declaration print '-- Multi Line Declaration --' test_str = ''' test_1 test_2 ''' print test_str # Connection to String print '-- Connection to String --' connect_str = 'python' connect_str = connect_str + '-' connect_str = connect_str + 'connect' # Add to String print '-- Add to String --' add_str = '012' add_str += '345' add_str += '678' add_str += '9' print add_str # Add to String print '-- Add to String --' repear_str = '012' * 3 print repear_str # Transform String print '-- Transform String --' trans_str = 100 print str(trans_str) + 'en' # Split String print '-- Split String --' split_str = 'python-sample' print split_str.split('-') # Alignment String print '-- Alignment String --' align_str = '1234' print align_str.rjust(10,'0') print align_str.rjust(10,'!') zfill_str = '1234' print zfill_str.zfill(10) print zfill_str.zfill(3) # Search String print '-- Search String --' search_str = 'python_sample' print search_str.startswith('python') print search_str.startswith('sample') print 'z' in search_str print 's' in search_str # B to S, S to B Search string trans_str = 'Python-Sample.Com' print trans_str.upper( ) print trans_str.lower( ) # Delete Char First,End print '------------------------------------' test_str = 'Code python-Sample.com' print test_str test_str = test_str.lstrip( ) print test_str test_str = test_str.lstrip('python') print test_str print '------------------------------------' test_str = 'python-Sample.com Code' print test_str + '/' test_str = test_str.rstrip( ) print test_str + '/' test_str = test_str.rstrip('com') print test_str #Quit() # -*- Application End -*-