python趣味输出/彩色/emoji

本文介绍了如何利用Python的emoji库为文本添加表情,并结合colorama库实现彩色终端输出,提升代码娱乐性和可读性。

python趣味输出/彩色/emoji

为了使 python 的输出更有趣味性, 也是增加一些编程的乐趣, 因此我们今天尝试做一些趣味的结果打印. 主要基于两个库: emojicolorama

emoji

安装

# https://github.com/carpedm20/emoji  or https://anaconda.org/conda-forge/emoji
##  conda install -c conda-forge emoji
pip install emoji --upgrade

示例:

>> import emoji
>> print(emoji.emojize('Python is :thumbs_up:'))
Python is 👍
>> print(emoji.emojize(
就是普通的python文件运行报错:/usr/bin/python3 /Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 64866 --file /Users/shenxin/Desktop/176All/project/jiaoben/scriptproject/great/takealot_review250609amz/takealot_review_20250609amz.py AmazonCategories_20241018.csv _tal AmazonCategories_20241018_1.csv > outputamz.log 2>&1 & Connected to pydev debugger (build 223.8836.43) /Users/shenxin/Desktop/176All/project/jiaoben/scriptproject/great/takealot_review250609amz/takealot_review_20250609amz.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp /Library/Python/3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020 warnings.warn( Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/Library/Python/3.9/site-packages/emoji/__init__.py", line 1, in <module> from .models import Emoji as emoji_class File "/Library/Python/3.9/site-packages/emoji/models.py", line 14, in <module> from . import settings File "/Library/Python/3.9/site-packages/emoji/settings.py", line 5, in <module> EMOJI_IMG_TAG = getattr(settings, 'EMOJI_IMG_TAG', ( File "/Users/shenxin/Library/Python/3.9/lib/python/site-packages/django/conf/__init__.py", line 79, in __getattr__ self._setup(name) File "/Users/shenxin/Library/Python/3.9/lib/python/site-packages/django/conf/__init__.py", line 60, in _setup raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting EMOJI_IMG_TAG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. python-BaseException Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_xml.py", line 161, in _get_type def _get_type(self, o, type_object, type_name): File "/Users/shenxin/Library/Python/3.9/lib/python/site-packages/django/utils/functional.py", line 254, in inner def inner(self, *args): File "/Users/shenxin/Library/Python/3.9/lib/python/site-packages/django/conf/__init__.py", line 51, in _setup def _setup(self, name=None): django.core.exceptions.ImproperlyConfigured: Requested settings, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. Process finished with exit code 1
最新发布
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

或许,这就是梦想吧!

如果对你有用,欢迎打赏。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值