Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the code commonly used by beginners in Python code

Shulou Source: shulou.com Published: 2022-06-02 23:27:14 09月10日 Update

Today, I will talk to you about what the code commonly used by beginners in Python code is, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Mainly record some code commonly used by beginners:

1. Get the current time

#-*-coding: gbk-*-import os import time import shutil today = time.strftime ('% Y-%m-%d week% w') now = time.strftime ('% HV% MVD% S') >

Common properties of 2.os.path

Os.path.sep: path separator. I used to use'/', but then I used'/'.

Os.path.altsep: (root directory, I'm not sure, I use it as root directory. Anyway, the performance in windows is'/')

Os.path.curdir: current directory

Os.path.pardir: parent directory

3. Determine whether it is a specified file type

File.rsplit ('.', 1) [- 1] = = type

Of course, it can be written as

File.split ('.') [- 1:] [0] = = type after reading the above, do you have any further understanding of what is commonly used by beginners in Python code? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Code beginners commonly used content root directory delimiter properties common file time week more current knowledge article type industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei NVidia Redmi macOS Shulou Information