raw_table = (''' a: Ask y: Dividend Yield
b: Bid d: Dividend per Share b2: Ask (Realtime) r1: Dividend Pay Date b3: Bid (Realtime) q: Ex-Dividend Date p: Previous Close o: Open''') key_name = raw_table.rstrip('\t') print(key_name) a: Ask y: Dividend Yield b: Bid d: Dividend per Share b2: Ask (Realtime) r1: Dividend Pay Date b3: Bid (Realtime) q: Ex-Dividend Date p: Previous Close o: Open #why is the tab not being removed? key_name = raw_table.rstrip('\n') print(key_name) a: Ask y: Dividend Yield b: Bid d: Dividend per Share b2: Ask (Realtime) r1: Dividend Pay Date b3: Bid (Realtime) q: Ex-Dividend Date p: Previous Close o: Open # why is the \n not being removed? key_name = raw_table.split('\t') print(key_name) ['\na: Ask', 'y: Dividend Yield\nb: Bid', 'd: Dividend per Share\nb2: Ask (Realtime)', 'r1: Dividend Pay Date\nb3: Bid (Realtime)'. #great the tab is being removed but now I have to remove the \n but it is no longer a string key_name = raw_table.split('\n') print(key_name) ['', 'a: Ask\ty: Dividend Yield', 'b: Bid\td: Dividend per Share', 'b2: Ask (Realtime)\tr1: Dividend Pay Date', 'b3: Bid (Realtime)\tq: Ex-Dividend Date'. #great, the \n is being "removed" but now I have to remove the \t, but it is no longer a string key_name = raw_table.split('\t\n') print(key_name) ['\na: Ask\ty: Dividend Yield\nb: Bid\td: Dividend per Share\nb2: Ask (Realtime)\tr1: Dividend Pay Date\nb3: Bid (Realtime)\tq: Ex-Dividend Date\n. #why isn't the \t and \n not both "removed" key_name = raw_table.rstrip('[\t\n]') a: Ask y: Dividend Yield b: Bid d: Dividend per Share b2: Ask (Realtime) r1: Dividend Pay Date b3: Bid (Realtime) q: Ex-Dividend Date p: Previous Close o: Open #why aren't both the \t and \n being removed? (tried with and without the square brackets) I am trying to get to where I can create a dict using the ':' separator Thanks Clayton
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor