From aeb5e2082bffe0d9d8ba57aa26fef7c3756a48d1 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Mon, 13 Jun 2022 19:29:48 +0800 Subject: [PATCH] 0.0.92 --- PyPI/setup.cfg | 2 +- PyPI/src/guan/__init__.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 00d2f98..ae943ac 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.91 +version = 0.0.92 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index e300baf..4328294 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -277,6 +277,10 @@ guan.write_one_dimensional_data(x_array, y_array, filename='a', format='txt') guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='txt') +hex = guan.rgb_to_hex(rgb, pound=1) + +rgb = guan.hex_to_rgb(hex) + # Module 11: plot figures @@ -2200,7 +2204,16 @@ def batch_reading_and_plotting(directory, xlabel='x', ylabel='y'): x_array, y_array = guan.read_one_dimensional_data(filename=filename) guan.plot(x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=filename, show=0, save=1, filename=filename) +def rgb_to_hex(rgb, pound=1): + if pound==0: + return '%02x%02x%02x' % rgb + else: + return '#%02x%02x%02x' % rgb +def hex_to_rgb(hex): + hex = hex.lstrip('#') + length = len(hex) + return tuple(int(hex[i:i+length//3], 16) for i in range(0, length, length//3))