I want to write an import statement in one line.

Asked 1 years ago, Updated 1 years ago, 308 views


to distinguish Python's Pillow packages from other packages, as follows: I'd like to use it with the prefix pil, but after trying various things, I couldn't achieve it without two lines of import statement.Could you import it in one line?

import PIL aspil
from PIL import ImageFont

func=pil.ImageFont.truetype

For example, you can do it without a prefix as shown below.I'd like to add the prefix pil to ImageFont.

import PIL.ImageFont as ImageFont
func=ImageFont.truetype

Also, PIL is

 pip3 install pillow

I installed it in .

python python3

2023-02-15 17:32

1 Answers

Could you import it in one line?

import PIL aspil; from PIL import ImageFont


2023-02-15 22:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.