& gt;> X=string. Who + string. Ascii_letters + string. Punctuation & gt;> Pick=STR. Join ([the random choice (x) for I in range (8)]) Traceback (the most recent call last) : File " Pick=STR. Join ([the random choice (x) for I in range (8)]) TypeError: descriptor 'join' for 'STR' objects doesn 't apply to a' list 'object & gt;> Table=STR. Maketrans (' abcdef123 ', 'sirmvyela) > why pick function compilation is not successful, the following table function can succeed? I look at the format??
CodePudding user response:
STR. Join function using the premise is to set up the first specified characters, to each element in a sequence of connected again! So before pick assignment statement, you can give the STR assignment STR='
Then pick=...
CodePudding user response:
Do not conform to the obvious type
CodePudding user response:
1, is your STR is not defined, STR=", "try it? 2, I don't know what is your X, string? , if the string is, should be no problem S1=[01 ""," 2 ", "3", "01", "2", "3", "01", "2", "3", "01", "2", "3"] STR=", " Print (STR. Join (s1)) Print (STR. Join ([the random choice (" adfaf ") for I in range (8)]))