我有一個這樣的字符串,從文本文件中讀取行後:字符串元組轉換在python
To = "'[email protected]','[email protected]','[email protected]','[email protected]','[email protected]'"
我想將其轉換爲一個元組。我做的是:
To = (To,)
type(To) #o/p tuple
len(To) #1
To
("'[email protected]','[email protected]','[email protected]', '[email protected]','[email protected]'",) # output tuple
預期的那樣,我需要通過,
每個值分開,它從字符串或元組轉換後存儲到一個元組:
To
('[email protected]','[email protected]','[email protected]', '[email protected]','[email protected]',) # output tuple
len(To) #should give 5
我回答了你幾個小時前問過的鏈接副本中的問題。 – TigerhawkT3