29 Oct 2022

Python Tip: Get Filename, Extension, Parent Folder, File Existence, and More

收藏到CSDN网摘




From time to time, a very common task might be to get the file name, extension, parent folder, or checking the exitance of a file or file list. In Python, this can be done by the in-built os.path library. Here is how!

27 Oct 2022

Python Tip: Get Variable Name in Python (type of reflection?)

收藏到CSDN网摘




Sometimes, you may want to get the variable name itself as a string while writing Python code. For instance, if you are going to write 'a = 2', is there a convenient way of getting the variable name '"a"' by calling a function using 'a' as the parameter? The short answer is YES.

21 Oct 2022

Get Date and Time String in Python

收藏到CSDN网摘

It's a very common task that you may need the current date and time as a string, which can then be assigned as a timestamp for logging, intermidiate input deck generation, etc. In Python, there are several modules available to achieve this, such as date, time, datetime - well, it looks redudent here! The easierest way might be using the time module.

30 Sept 2022

Change Matlab Command Window's Text Colour

收藏到CSDN网摘

Matlab has provided some coloured text features already. For instance, the default 'disp' or 'fprintf' will print text in balck colour, while 'warning' displays text in orange and 'error' displays text in red (yes, error also terminates your script). But someone may want more flexibilities over these default one. Fortunately, there are some work around available for this issue.

27 Jun 2022

Dive into Deep Learning Online Book

收藏到CSDN网摘

2本跟机器学习有关的在线电子书,涉及线性回归、多项式拟合、模型阶数选择等概念,很详细,值得精读。

2 Nov 2021

Get One Line or Count the Number of Lines, Words, Characters in PowerShell

收藏到CSDN网摘

PowerShell is replacing cmd.exe in the new Windows operating systems, it's more efficient and powerful than its predecessor. The only drawback might be that the commands are much longer than what we used to see in cmd.exe. Counting the lines, words, even the characters are very useful - well, sometimes at least. This task can be easily done using some GUI software such as MS Word, Notepad, or vim if you prefer. PowerShell is capable of doing these jobs as well. Here is how ~