Beyond the Basic Stuff with Python
2021/8/19 12:06:07
本文主要是介绍Beyond the Basic Stuff with Python,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Beyond the Basic Stuff with Python
-
-
Introduction
-
Chapter 1 - Dealing with Errors and Asking for Help
-
Chapter 2 - Environment Setup and the Command Line
-
Chapter 3 - Code Formatting with Black
-
Chapter 4 - Choosing Understandable Names
-
Chapter 5 - Finding Code Smells
-
Chapter 6 - Writing Pythonic Code
-
Chapter 7 - Programming Jargon
-
Chapter 8 - Common Python Gotchas
-
Chapter 9 - Esoteric Python Oddities
-
Chapter 10 - Writing Effective Functions
-
Chapter 11 - Comments, Docstrings, and Type Hints
-
Chapter 12 - Organizing Your Code Projects with Git
-
Chapter 13 - Measuring Performance and Big O Algorithm Analysis
-
Chapter 14 - Practice Projects
-
Chapter 15 - Object-Oriented Programming and Classes
-
Chapter 16 - Object-Oriented Programming and Inheritance
-
Chapter 17 - Pythonic OOP: Properties and Dunder Methods
-
C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | C10 | C11 | C12 |
---|---|---|---|---|---|---|---|---|---|---|
100 |
C1 处理错误及请求帮助。
python “ZeroDivisionError: division by zero” #搜索时打引号
1. 三步处理错误:
-
Examining Tracebacks
-
Searching for Error Messages
-
Preventing Errors with Linters
-
关于安装linter:
You can install Pyflakes(一种a linter) from https://pypi.org/project/pyflakes/ or by running pip install --user pyflakes
.
*On Windows, you can run the* python and pip commands. But on macOS and Linux, these command names are for Python version 2 only, so instead you’ll need to run python3 and pip3*
2. 请求帮助
-
官方引导: https://www.python.org/about/help/
-
https://www.reddit.com/r/learnpython/
-
储存代码格式的网站 https://pastebin.com/
-
附上了一个好的问题格式。
C2 环境设置和命令行
内容包括: 文件系统,路径,home目录(系统盘所在的位置),当前工作文件夹,绝对路径,相对路径,程序和进程; 命令行、打开终端窗口、输入命令行运行程序、命令行参数、-c参数来运行python、命令行运行python、运行py.exe.程序、用python模块subprocess运行shell commands、Tab快捷输入、查看命令行历史(W:doskey /history ;咋不管用, history
command)
* 常用命令行--可以查“Linux与Windows命令对比”
-
通配符匹配文件夹和文件名,如dir *.py
-
切换目录 cd
* home文件夹:
cd ~
on macOS and Linux;cd %USERPROFILE%
on Windows* 文件夹有空格,要加双引号。
* windows切换盘 用
d:
; 返回上一层cd ..
-
列出目录dir和ls
ls -al可以出现更多信息: Linux和macOS
-
找文件
* windows:
dir /s *.py
遍历父和子文件夹取找py文件* 同样的命令:
find . -name "*.py"
注意后面打了引号。 -
复制文件和文件夹
copy [source file or folder] [destination folder]
cp
[source file or folder] [destination folder]
-
移动文件和文件夹
move [source file or folder] [destination folder]
mv[source file or folder]``[destination folder]
-
使用ren and mv重命名
ren[file or folder] [new name]
mv[file or folder] [new name]
-
删除文件
del[file or folder]
#只删除文件,不删除文件名,不影响子文件夹,del /s /q [file or folder]
安静地删除所有文件,包含子文件夹里的文件,非文件夹。rm[file]
rd /s /q [folder]
#删除windows整个文件夹rm –r[folder]
#删除linus/macOS整个文件夹 -
新建文件夹
md[new folder]
-
删除文件夹
rd[source folder]
: widnowsrmdir[source folder]
: macOS and Linux -
找程序的目录
where
[program] on Windows ;不知道为什么, 我这个只能用powershell输入gcm查询which
[program] on macOS and Linux -
清空终端窗口
cls
on Windowsclear
on macOS
* 环境变量和路径
-
查看环境变量
set
(on Windows) orenv
(on macOS and Linux)查看home环境变量
echo
command. Runecho %HOMEPATH%
on Windows orecho $HOME
on macOS and Linux环境变量的顺序有先后
-
临时变更环境变量
path C:\newFolder;%PATH%
PATH=/newFolder:$PATH
-
永久变更环境变量
setx /M PATH "C:\newFolder;%PATH%"
export PATH=/newFolder:$PATH
-
方便运行python的方法
windows:以下文件保存为.bat。
@py.exe C:\path\to\yourScript.py %* @pause
linux需要保存到home文件夹中,.py文件首行写
#!/usr/bin/env python3
(shebang line),输入./yourScript.py
运行。chmod u+x yourScript.py
这篇关于Beyond the Basic Stuff with Python的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24Python编程入门指南
- 2024-12-24Python编程基础入门
- 2024-12-24Python编程基础:变量与数据类型
- 2024-12-23使用python部署一个usdt合约,部署自己的usdt稳定币
- 2024-12-20Python编程入门指南
- 2024-12-20Python编程基础与进阶
- 2024-12-19Python基础编程教程
- 2024-12-19python 文件的后缀名是什么 怎么运行一个python文件?-icode9专业技术文章分享
- 2024-12-19使用python 把docx转为pdf文件有哪些方法?-icode9专业技术文章分享
- 2024-12-19python怎么更换换pip的源镜像?-icode9专业技术文章分享