I'm trying to write a very simple address book webapp in Python. I'm new to Python but have had a fair amount of time writing in Perl, I want to know what is the equivalent to Perl's warn
function in Python 3.6.
If you are looking for the equivalent of raising warnings you can use pythons warnings
module like so:
from warnings import warn
warn('Your message here', Warning)
This will display __main__:1: Warning: my message here
on stderr.
If you are looking for the equivalent of raising errors you can use pythons Exception
class like so:
raise Exception('Your message here')
This will display Exception: Your message here
on stderr.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.