我想执行以下命令:
python -c "import os, random, string; for _ in range(30): os.mkdir(''.join(random.choice(string.ascii_lowercase) for _ in range(random.randint(3, 10))))"
但我得到了:
File "<string>", line 1
import os, random, string; for _ in range(30): os.mkdir(''.join(random.choice(string.ascii_lowercase) for _ in range(random.randint(3, 10))))
^
SyntaxError: invalid syntax
为什么会出现此错误?
与换行符相同且没有分号的代码:
import os, random, string
for _ in range(30):
os.mkdir(''.join(
random.choice(string.ascii_lowercase) for _ in range(random.randint(3, 10))
))