HaoTian's Python Util
Project description
htutil
HaoTian's Python Util
Install
pip install htutil
Usage
file
from htutil import file
Refer to C# System.IO.File API, very simple to use.
s = 'hello'
write_text('1.txt', s)
# hello in 1.txt
append_text('1.txt', 'world')
# helloworld in 1.txt
s = read_text('1.txt')
print(s) # helloworld
s = ['hello', 'world']
write_lines('1.txt', s)
# hello\nworld in 1.txt
append_lines('1.txt',['\npython'])
# hello\nworld\npython in 1.txt
s = read_lines('1.txt')
print(s) # ['hello', 'world', 'python']
cache
cache def result by pickle file.
from htutil import cache
@cache.file_cache
def get_1():
time.sleep(3)
return 1
counter
a simple counter based on dict.
c = Counter()
c.add('1')
c.add('1')
c.add('2')
print(c.to_dict()) # {'1': 2, '2': 1}
c.dump() # same as print(c.to_dict())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
htutil-3.2.0.tar.gz
(15.0 kB
view hashes)
Built Distribution
htutil-3.2.0-py3-none-any.whl
(16.0 kB
view hashes)